我试图隐藏显示或不在单个产品页面上显示选项卡,具体取决于$ sizeGridNumber的值。因此,如果此值为1或为空,我希望不显示选项卡。我返回一个空数组,但它会产生错误。
/*Customise additional-information tab (Size Grid)*/
add_filter( 'woocommerce_product_tabs', 'wpb_custom_additional_information_tab', 98 );
function wpb_custom_additional_information_tab( $tabs ) {
global $post;
// var_dump($post->ID);
$sizeGridNumber = get_post_meta( $post->ID, '_selectsizeguide', true );
$sku = get_post_meta( $post->ID, '_sku', true );
// echo '<br/>';
// var_dump($sizeGridNumber);
// print_r($sizeGridNumber);
// var_dump($sku);
// print_r($sku);
if ( $sizeGridNumber == 1 || $sizeGridNumber == "") {
echo "on passe";
return array();
} else {
$tabs['additional_information']['callback'] = 'wpb_custom_additional_information_tab_content'; // Custom additional_information callback
return $tabs;
}
}