2

I found this post: Remove price from Woocommerce variable product dropdown menu, but it hides ALL variable prices. Instead I would like to hide the variable price if it is $0.00.

Can anyone help me with this?


Edit:

I didn't realize that the variation prices weren't part of WooCommerce. I am using WooCommerce Product Add-ons. I found this snippet that will target a specific product, but I don't know how to convert it to if !$0.00 condition. This post closer identifies my issue:
Hide displayed product prices from Woocommerce Product Add-ons Fields

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
joy
  • 101
  • 9

1 Answers1

1

Based on Hide displayed product prices from Woocommerce Product Add-ons Fields answer code, you can try to use something like:

add_filter( 'woocommerce_product_addons_option_price', 'filter_product_addons_option_price', 10, 4 );
function filter_product_addons_option_price( $price_html, $option, $i, $type ){
    if( isset($option['price']) && ! ( $option['price'] > 0 ) ) {
        $price_html = '';
    }
    return $price_html;
}

Code goes in functions.php file of the active child theme (or active theme). It could works.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • Hi Loic, thanks so much for the suggestion and your help again. The option price is actually required to be set for the option to appear on the front end - so the price is set at 0.00. It seems this logic won't trigger since there is a price that is set. :-) I also got an error for the last quote marks that I needed to remove from the if statement after $price_html, I don't know if that would have any effect. – joy Nov 10 '20 at 22:48
  • 1
    @joy Just updated again, removed a mistake and some code that I forgot to remove. – LoicTheAztec Nov 10 '20 at 22:53