Skip to content

Instantly share code, notes, and snippets.

@jameskoster
Created November 17, 2014 17:15
Show Gist options
  • Save jameskoster/c0cc71c71147ea66b8c2 to your computer and use it in GitHub Desktop.
Save jameskoster/c0cc71c71147ea66b8c2 to your computer and use it in GitHub Desktop.
WooCommerce - hide variable product price range
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' );
@Galaxy65
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment