I have WordPress Measurement Price Calculator installed on my WooCommerce online shop.
My issue is that I have attribute "Dimension" used for products on my shop and I would like to only display Measurement Price Calculator for one of dimensions (one variation) which is "Custom size".
If I select any other dimension like "170 x 240" it is still requesting to provide the dimension (displaying width missing, length missing error) as it won't add the product to the cart.
I have tried to force calculator to not display using Product Variation settings / Measurement settings with no luck.
So now I'm trying to do this using function.php code.
The code which I've tried to use is:
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_calculator_enabled( $_product ) ) {
return '';
}
return $price_html;
}
but it doesn't work.
I don't know how to filter it to display only for Variation equal to "Custom size" for attribute "Dimension".
Could somebody encountered such issue and maybe could tell me how to modify it to work correctly?