ThomasLarge
10/30/2017 - 5:33 PM

WooCommeres Helpers

WooCommeres Helpers

// Add a button when there is no price displayed - edit price.php

<p class="price"><?php echo $product->get_price_html(); ?></p> // Remove this and replace with

<p itemprop="price" class="price">

    <?php 
        $price = $product->get_price_html();
        if(empty($price))
        {
            echo '<a href="link">Anchor Text</a>';
        }
        else
        {
            echo $price;
        }; 
    ?>

</p>


// Display Price For Variable Product With Same Variations Prices

add_filter('woocommerce_available_variation', function ($value, $object = null, $variation = null) {
  if ($value['price_html'] == '') {
     $value['price_html'] = '<span class="price">' . $variation->get_price_html() . '</span>';
  }
  return $value;
}, 10, 3);