Last active
December 18, 2015 00:59
-
-
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
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
<?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