Hi,
I added a custom function to add custom product tabs for woocommerce, that grab content from “advanced custom fields” plugin. It ist working fine. Problem is, I want to hide the complete tab if empty.
how can I add this function to my code:
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab_1' );
function woo_new_product_tab_1( $tabs ) {
$tabs['downloads'] = array(
'title' => __( 'Downloads', 'woocommerce' ),
'priority' => 40,
'callback' => 'show_downloads'
);
return $tabs;
}
function show_downloads() {
echo get_field( 'downloads' );
}
Am trying to do a similar thing – not sure if you figured it but I found the answer at bloke.com. Add to functions.php
I’m trying to take it a step further and want to display a repeater field in the tab and can’t figure it out. Any Woocommerce gurus out there that can help?
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
global $post, $product;
$ingredients = get_post_meta($post->ID, 'ingredients', TRUE);
// Adds the new tab
if (!empty($ingredients)) {
$tabs['test_tab'] = array(
'title' => __( 'Ingredients', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
}return $tabs;
}
function woo_new_product_tab_content() {
global $post, $product;
$ingredients = get_post_meta($post->ID, 'ingredients', TRUE);
echo($ingredients);
}