Support

Account

Home Forums Front-end Issues Only Show Tabs if there's content? Reply To: Only Show Tabs if there's content?

  • 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);
    }