Home > Software design >  hide the price for protected products in shop page WooCommerce
hide the price for protected products in shop page WooCommerce

Time:04-29

how to hide the price for protected products in shop page WooCommerce ?

CodePudding user response:

There are 2 option:

1- If you want that nothing product have price, you can convert on-line shop in catalog mode. For setting in catalog mode you have install a plugin for example I use YITH WOOCOMMERCE CATALOG MODE.

2- if It's only a product, Just you not put a price when config the product in woocomerce/products.

CodePudding user response:

To hide the price for protected products you can add a filter for displaying the price html and check if the product is protected, by checking to see if a password has been set, and if so return no value.

add_filter( 'woocommerce_get_price_html', 'hide_protected_product_price', 10, 2 );
function hide_protected_product_price( $price, $product ) {
    if ( ! empty( $product->get_post_password() ) ) {
        return '';
    }
    return $price;
}
  • Related