Hide variation price, if 0.00?
-
Hello,
we have got some medical products, that can be bought as direct payer with the regular price or on prescription, where the price (0.00) isn’t shown for the user. These products have got two variations to chose the payment method on the single product page.
The PHP code to replace the price with a “prescription” text, when it’s a prescription product still works in cart and checkout, but on the single product page I cannot hide the price for the selected variation, if it’s prescription (every prescription variation has got a shortcode for an info box in the description, that is shown to the user instead of the price).
In WooCommerce 2.x we added this code:
function changeFreePriceNotice($price, $product) { return ''; } add_filter('woocommerce_variable_free_price_html', 'changeFreePriceNotice', 10, 2); add_filter('woocommerce_variation_free_price_html', 'changeFreePriceNotice', 10, 2);
(Original source, changed to zero text and to only change the variation price)
In WooCommerce 3 it doesn’t work anymore and I can’t find a working alternative.
If this ain’t possible anymore, is it possible to add e.g. the variation shipping class (the alias) into /single-product/add-to-cart/variation.php, so that the price can be hidden via CSS?
This didn’t work (even without “_”):
<div class="woocommerce-variation-price {{{ data.variation.shipping_class }}}">
I could’t find any documentation, which parameters can be added.
- The topic ‘Hide variation price, if 0.00?’ is closed to new replies.