skip to Main Content

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

2

Answers


  1. 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 );  
    }
    }
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search