Skip to content

Instantly share code, notes, and snippets.

@ThomasLarge
Last active May 1, 2018 09:37
Show Gist options
  • Save ThomasLarge/e171635c3605539f5ecc2359d8a3177c to your computer and use it in GitHub Desktop.
Save ThomasLarge/e171635c3605539f5ecc2359d8a3177c to your computer and use it in GitHub Desktop.
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment