Следующее будет скрывать эту настраиваемую вкладку, если краткое описание продукта пусто:
// Add short description as a new custom product tab
add_filter( 'woocommerce_product_tabs', 'add_custom_product_tab' );
function add_custom_product_tab( $tabs ) {
global $post, $product;
$short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );
if ( ! empty($short_description) ) {
$tabs['short_description'] = array(
'title' => __( "What's in the box", "woocommerce" ),
'priority' => 200,
'callback' => 'short_description_tab_content'
);
}
return $tabs;
}
// Custom product tab content
function short_description_tab_content() {
global $post, $product;
$short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );
if ( ! empty($short_description) ) {
echo '<div class="woocommerce-product-details__short-description">' . $short_description . '</div>'; // WPCS: XSS ok.;
}
}
Код входит в functions. php файл вашей активной дочерней темы (или активной темы). Проверено и работает.