【发布时间】:2021-01-29 17:36:34
【问题描述】:
基于此代码,我想为 WooCommerce 4.4.1 中的可变产品创建自定义选项卡。
但不幸的是,这个自定义标签被添加到所有产品类型中,有什么办法可以解决这个问题吗?
如果我错了,请纠正我。
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab for variable product type
global $product;
if( $product->is_type( 'variable' ) ) {
$tabs['test_tab'] = array(
'title' => 'features',
'priority' => 50,
'class' => array('general_tab', 'show_if_variable'),
'callback' => 'woo_new_product_tab_content'
);
}
return $tabs;
}
【问题讨论】:
-
如果您有一些非可变产品,我猜这应该可以工作。也许让你的网站打印产品类型,你会看到发生了什么
标签: php wordpress woocommerce tabs product