• 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.

    • This topic was modified 7 years, 8 months ago by Apfelbiss.
Viewing 2 replies - 1 through 2 (of 2 total)
  • If you need to hide the prices for all products in your store that are variable, the following could work:

    .variations_form .price {display:none;}

    add this to your theme custom CSS.

    Thread Starter Apfelbiss

    (@apfelbiss)

    Hi,

    no, thanks. For regular products the user has to see the price. Only for prescription products the price has to be hidden.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide variation price, if 0.00?’ is closed to new replies.