Manish Pushkar Jha
Manish Pushkar Jha

Reputation: 138

How to hide Woocommerce product Description tab only for unlogged users?

How to hide product "Description" tab' in Woocommerce plugin only for unlogged users, but visible for registered customers (and logged-in users).

Upvotes: 0

Views: 1234

Answers (2)

LoicTheAztec
LoicTheAztec

Reputation: 253968

To remove product description tab on sigle product pages for non logged users, you will use:

add_filter( 'woocommerce_product_tabs', 'customize_product_tabs', 100 );
function customize_product_tabs( $tabs ) {

    if ( ! is_user_logged_in() ) { 
        unset( $tabs['description'] ); // remove the description tab
    }

    return $tabs;
}

This code goes in functions.php file of your active child theme (or active theme). Tested and works.

Upvotes: 1

Earid
Earid

Reputation: 842

Try this, add this snippet into the function.php

add_action( 'init', 'hide_price_add_cart_not_logged_in' );

function hide_price_add_cart_not_logged_in() { 
if ( !is_user_logged_in() ) {       

//Remove short description (excerpt) from single product page
remove_action( 'woocommerce_product_tabs', 'woocommerce_template_single_excerpt', 20 );  
}
}

Upvotes: 1

Related Questions