Created
May 23, 2014 16:17
-
-
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/
This file contains hidden or 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
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where O should save this file? in which folder/path?