• Resolved davidzupec

    (@davidzupec)


    I added an additional tab (ingredients) and it worked great. However, I need to add another tab so I just duplicated this code but that didn’t work. Any Suggestions? Thank you!

    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
    function woo_new_product_tab( $tabs ) {
    
    	// Adds the new tab
    
    	$tabs['test_tab'] = array(
    		'title' 	=> __( 'Ingredients', 'woocommerce' ),
    		'priority' 	=> 50,
    		'callback' 	=> 'woo_new_product_tab_content'
    	);
    
    	return $tabs;
    
    }
    function woo_new_product_tab_content() {
    
    	// The new tab content
    
    	echo '<h2>Product Ingredients</h2>';
    
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi davidzupec,

    Are both of your functions named the same? You will need to have separate names for each function so they register properly.

    If that doesn’t help, can you send me all the code that you used to add both Tabs so I can check?

    Thread Starter davidzupec

    (@davidzupec)

    Hey Mikey, this is the code for adding the second tab…

    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
    function woo_new_product_tab( $tabs ) {
    
    	// Adds the new tab
    
    	$tabs['shippinginfo_tab'] = array(
    		'title' 	=> __( 'Shipping Info, 'woocommerce' ),
    		'priority' 	=> 50,
    		'callback' 	=> 'woo_new_product_tab_content'
    	);
    
    	return $tabs;
    
    }
    function woo_new_product_tab_content() {
    
    	// The new tab content
    
    	echo '<h2>Shipping Info</h2>';
    
    }

    Thank you!

    Hi davidzupec,

    It looks like both functions are named the same thing woo_new_product_tab which is why it won’t work. You will need to have the functions named differently, and also that new function name to be hooked in to the add_filter as well.

    Cheers,

    Thread Starter davidzupec

    (@davidzupec)

    Great, thank you Mikey. I appreciate your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding additional tabs in product details page’ is closed to new replies.