I'm trying to figure out how to hide a custom tab that was created in the theme customizer settings by the theme when the tab is empty.
Here is the code that displays the custom tab on my product page:
<a class="rey-summaryAcc-accItem --active" href="#acctab-custom_tab_0"> <span>Shipment Parts</span>
and
<div class="rey-summaryAcc-item rey-summaryAcc-item--custom_tab_0 " id="acctab-custom_tab_0" role="tabpanel" aria-labelledby="acctab-title-custom_tab_0" style="display: block;"><div class="__inner"> <input type="hidden" id="show_price" value="yes">
I tried using this code from this post but my tab is still showing.
// Add a custom product tab on single product pages
add_filter( 'woocommerce_product_tabs', 'woo_new_tab' );
function woo_new_tab( $tabs ) {
$values = get_field('acctab-custom_tab_0');
// Adds the new tab
if ( ! empty($values) ) {
$tabs['acctab-custom_tab_0'] = array(
'title' => __( 'Test', 'woocommerce' ),
'priority' => 20,
'callback' => 'woo_new_tab_content'
);
}
return $tabs;
}
// Displays the tab content
function woo_new_tab_content() {
$values = (array) get_field('acctab-custom_tab_0');
echo '<ul>';
foreach ( $values as $value ) {
echo '<li>' . $value . '</li>';
}
echo '</ul>';
}
What am I doing wrong?