且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

重命名 Woocommerce 单个产品页面中的描述选项卡

更新时间:2023-02-02 13:11:56

你忘记了过滤器钩子:

add_filter( 'woocommerce_product_tabs', 'woo_customize_tabs', 100, 1 );函数 woo_customize_tabs( $tabs ) {取消设置($tabs['评论']);//删除评论选项卡$tabs['description']['title'] = __( '更多信息' );//重命名描述选项卡返回 $tabs;}

代码位于活动子主题(或主题)的 function.php 文件或任何插件文件中.

所有代码都在 Woocommerce 3+ 上进行了测试并且可以正常工作.

更新(与您的评论相关) |重命名产品描述标题(在选项卡内):

要重命名描述标题,请使用 woocommerce_product_description_heading 过滤器挂钩:

add_filter( 'woocommerce_product_description_heading', 'rename_product_description_heading', 10, 1 );函数 rename_product_description_heading( $heading ) {返回 __( '附加信息', 'woocommerce');}

代码位于活动子主题(或主题)的 function.php 文件或任何插件文件中.

所有代码都在 Woocommerce 3+ 上进行了测试并且可以正常工作.

官方相关文档:编辑商品数据标签>

I pasted this code in function.php, but it didn't rename the product page tab as it supposed to (http://www.noushasasart.com/product/harsh-bark/)

function woo_remove_product_tabs($tabs) {
    unset($tabs['reviews']);    // Remove the reviews tab
    $tabs['description']['title'] = __('Additional Information');  // Rename the 

    description tab        
    return $tabs;
}

how can I solve this?

You have forgotten the filter hook:

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

    unset($tabs['reviews']);    // Remove the reviews tab

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

    return $tabs;
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

All code is tested on Woocommerce 3+ and works.


Update (related to your comment) | Rename product description heading (inside the tab):

To rename description heading use woocommerce_product_description_heading filter hook this way:

add_filter( 'woocommerce_product_description_heading', 'rename_product_description_heading', 10, 1 );
function rename_product_description_heading( $heading ) {
    return  __( 'Additional Information', 'woocommerce' );
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

All code is tested on Woocommerce 3+ and works.


Official related documentation: Editing product data tabs