Created
November 17, 2014 17:15
-
-
Save jameskoster/c0cc71c71147ea66b8c2 to your computer and use it in GitHub Desktop.
WooCommerce - hide variable product price range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jk_variable_product_price( $price ) { | |
global $product; | |
$product = new WC_Product_Variable( $product ); | |
$min_price = $product->get_variation_price( 'min', true ); | |
$max_price = $product->get_variation_price( 'max', true ); | |
// Hide the range if the min/max price doesn't match | |
if ( $min_price !== $max_price ) { | |
$price = ''; | |
} | |
return apply_filters( 'woocommerce_get_price_html', $price ); | |
} | |
add_filter( 'woocommerce_variable_price_html', 'jk_variable_product_price' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice work but I'm using Measurement Price Calculator Extension with Woocommerce and this error comes up:
Warning: Missing argument 2 for WC_Price_Calculator_Product_Page::price_per_unit_html() in /var/www/vhosts/acumulus.co.nz/httpdocs/verda/wp-content/plugins/woocommerce-measurement-price-calculator/classes/class-wc-price-calculator-product-page.php on line 280
Any ideas on this?
Cheers