首页 文章

Woocommerce:删除“其他信息”标签

提问于
浏览
1

我想在本网站的产品页面上做的两件事:https://lovesometea.com/product/green-coconut/

1)删除“附加信息”选项卡2)在产品描述上方添加属性“大小”

要删除"additional information"标签,我一直在关注此事:https://idevie.com/tutorials/how-to-make-woocommerce-product-attributes-more-prominent

所以这就是我所做的:1)添加了一个自定义插件并激活它 - http://code.tutsplus.com/tutorials/making-woocommerce-product-attributes-more-prominent--cms-25438

2)尝试通过编辑/ wp-content / plugins / woocommerce / templates / single-product / tabs中的tabs.php来删除“附加信息”

/**
 * Removes the "Additional Information" tab that displays the product attributes.
 * 
 * @param array $tabs WooCommerce tabs to display.
 * 
 * @return array WooCommerce tabs to display, minus "Additional Information".
 */
function tutsplus_remove_product_attributes_tab( $tabs ) {

    unset( $tabs['additional_information'] );

    return $tabs;

}

add_filter( 'woocommerce_product_tabs', 'tutsplus_remove_product_attributes_tab', 100 );

这就是我被困住的地方 . 我甚至尝试一起删除additional-information.php文件(在相同的标签文件夹中),并且仍然显示其他信息!

我尝试将上面的代码放在tabs.php文件的三个不同区域,但对产品页面上的选项卡没有影响 .

还有其他建议吗?也许最新的woocommerce版本有不同/更好的方法?

2 回答

  • 1

    这有助于我删除标签:

    在functions.php中添加:

    add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
    
    function woo_remove_product_tabs( $tabs ) {
    
        unset( $tabs['description'] );          // Remove the description tab
        unset( $tabs['reviews'] );          // Remove the reviews tab
        unset( $tabs['additional_information'] );   // Remove the additional information tab
    
        return $tabs;
    
    }
    

    要返回要在描述下显示的属性,我无法弄明白,所以我只是在描述中添加了大小

  • 0

    也许您需要将优先级从100更改为98,如woocommerce documentation,将代码放在functions.php文件中

    add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
    
    function woo_remove_product_tabs( $tabs ) {
    
        unset( $tabs['additional_information'] );   // Remove the additional information tab
    
        return $tabs;
    
    }
    

相关问题