Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Last active December 29, 2015 07:59
Show Gist options
  • Select an option

  • Save raphaelchaib/7640115 to your computer and use it in GitHub Desktop.

Select an option

Save raphaelchaib/7640115 to your computer and use it in GitHub Desktop.
[Always display WooCommerce variable product price] If all prices for a product’s variations are the same then variation price will not be displayed. But if it is the only displayed price then you are in trouble. To overcome this situation you can edit your template functions.php file like this:
<?php
// Display variation's price even if min and max prices are the same
add_filter('woocommerce_available_variation', 'variationPriceFix', 10, 3);
function variationPriceFix ($value, $object = null, $variation = null) {
if ($value['price_html'] == '') {
$value['price_html'] = '<span class="price">' . $variation->get_price_html() . '</span>';
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment