Skip to content

Instantly share code, notes, and snippets.

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/9f32ee9544307018c52f to your computer and use it in GitHub Desktop.
Save justinstern/9f32ee9544307018c52f to your computer and use it in GitHub Desktop.
WC Measurement Price Calculator customization to hide the product price per unit http://www.woothemes.com/products/measurement-price-calculator/
<?php
// Add the following to the bottom of your current theme's functions.php
add_filter( 'woocommerce_sale_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_empty_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_variable_sale_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_variable_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_variable_empty_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_variation_sale_price_html', 'remove_price_per_unit_html', 15, 2 );
add_filter( 'woocommerce_variation_price_html', 'remove_price_per_unit_html', 15, 2 );
function remove_price_per_unit_html( $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 = get_product( $product->id ); }
if ( class_exists( 'WC_Price_Calculator_Product' ) && WC_Price_Calculator_Product::pricing_per_unit_enabled( $_product ) ) {
return '';
}
return $price_html;
}
@matteoraggi
Copy link

where O should save this file? in which folder/path?

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