Additional Tabs - by TheOne - on WordPress WooCommerce support

This topic has 3 replies, 2 voices, and was last updated 5 years, 11 months ago ago by Rose Tyler

  • Avatar: TheOne
    TheOne
    Participant
    May 25, 2018 at 00:37

    Hey,

    On my single product pages i have a static tab set to display costum content.
    Now i want to add another seperate costum tab (which is also static for all the products).

    I tried to add the following code and CSS style:

    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
    function woo_new_product_tab( $tabs ) {
    // Adds the new tab
        $tabs['desc_tab'] = array(
            'title'     => __( 'Additional Information', 'woocommerce' ),
            'priority'  => 50,
            'callback'  => 'woo_new_product_tab_content'
        );
    }

    Content to costum tab:

    function woo_new_product_tab_content() {
      // The new tab content
      echo '<p>Lorem Ipsum</p>';
    }

    But the costum tab that i inputed in the 8Theme options gets erased. That got me thinking if the this code is overwritting yours ?

    Thank you,

    PS: If you could add an option for more costum tabs in future theme update that would be awesome!

    2 Answers
    Avatar: TheOne
    TheOne
    Participant
    May 25, 2018 at 00:39

    Edit: my mistake the second code is also for functions.php

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    May 25, 2018 at 07:27

    Hello,

    Please use the following snippet in functions.php file of child theme to add a custom global product tab:

    /**
     * Add a custom product data tab
     */
    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
    function woo_new_product_tab( $tabs ) {
    	
    	// Adds the new tab
    	
    	$tabs['test_tab'] = array(
    		'title' 	=> __( 'New Product Tab', 'woocommerce' ),
    		'priority' 	=> 50,
    		'callback' 	=> 'woo_new_product_tab_content'
    	);
    
    	return $tabs;
    
    }
    function woo_new_product_tab_content() {
    
    	// The new tab content
    
    	echo '<h2>New Product Tab</h2>';
    	echo '<p>Here\'s your new product tab.</p>';
    	
    }

    http://prntscr.com/jmcpi9

    Regards

  • Viewing 3 results - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.