Woocommerce - 根据所选的产品类别重命名产品标签[重复]

This question already has an answer here:

I was hoping to rename the default product DESCRIPTION TAB on single product page to a different name according to the product category selected.

I was initially coming out of the following WC function to rename the default description tab:

add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {

    $tabs['description']['title'] = __( 'More Information' );   // Rename the description tab

    return $tabs;

} 

Now what I would like to achieve is that if the product is assigned to category "Books", then the name of the description tab would change to "About this book". Then If the product is assigned to category "Videos", then the tab would change to "About this video" and if the product is assigned to any other category, the tab name would change to "More Information"

I tried to amend the code and this is what I came up with:

add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {

    global $product, $woocommerce;

    if ( is_product_category() ) {

        if ( is_product_category( 'books' ) ) {
           $tabs['description']['title'] = __( 'About this book' );
        } elseif ( is_product_category( 'videos' ) ) {
           $tabs['description']['title'] = __( 'About this video' );  
        } else {
           $tabs['description']['title'] = __( 'More Information' );
        }
    }

    return $tabs;
}

But unfortunately it doesn't seem to be working as the tab name is still "Description"

What am I doing wrong?

</div>

Change:

 is_product_category( 'books' ) to has_term( 'books', 'product_cat' )
 is_product_category( 'videos' ) to has_term( 'videos', 'product_cat' )

, and it should work.

Function is_product_category returns true only when viewing a product category page. But you are on single product page, that's why it returns FALSE.