Skip to content

Instantly share code, notes, and snippets.

@justinstern
Last active December 18, 2015 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinstern/5700683 to your computer and use it in GitHub Desktop.
Save justinstern/5700683 to your computer and use it in GitHub Desktop.
Hides the product page price per unit for woocommerce measurement price calculator products
<?php
add_filter( 'woocommerce_get_price_html', 'wc_hide_product_page_price_per_unit', 11, 2 );
function wc_hide_product_page_price_per_unit( $price_html, $product ) {
// if this is a product variation, get the parent product which holds the calculator settings
$_product = $product;
if ( isset( $product->variation_id ) && $product->variation_id ) { $_product = WC_Price_Calculator_Product::get_product( $product->id ); }
if ( WC_Price_Calculator_Product::pricing_per_unit_enabled( $_product ) && is_product() ) {
return '';
}
return $price_html;
}
add_filter( 'wc_measurement_price_calculator_get_pricing_rule_price_html', 'wc_measurement_price_calculator_get_pricing_rule_price_html', 10, 3 );
function wc_measurement_price_calculator_get_pricing_rule_price_html( $price_html, $rule, $settings ) {
return '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment