• Resolved charledeon

    (@charledeon)


    I was trying to re-order tabs, and I’ve copied the code from your site, but it’s not working.

    First I copied the code for adding tabs, and it worked. Next I want to re-order the tabs and I copied the same code as shown on your site, but it didn’t work.

    See my code:
    ———————————————————————————————————————–

    /**
    * Reorder product data tabs
    */
    add_filter( ‘woocommerce_product_tabs’, ‘woo_reorder_tabs’, 98 );
    function woo_reorder_tabs( $tabs ) {

    $tabs[‘description’][‘priority’] = 5; // Description first
    $tabs[‘specifications’][‘priority’] = 10; // Specifications second
    $tabs[‘reviews’][‘priority’] = 15; // Reviews third

    return $tabs;
    }

    ————————————————————————————————————————-

    See my screenshot– https://prntscr.com/ueo0xz

    What can I do?

    Waiting to hear from you soon.
    Regards

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there,

    It appears you are adding a Specifications tab, and removing the Additional Information Tab. However, as you show in your screenshot, the order is not changing.

    When you are Adding the Specification tab, are you also setting the priority to match what you are setting it as in the reorder function? i.e. I see you are setting it to priority 10 there, are you also setting it to 10 when adding the tab?

    I tried the following snippets, and they seemed to work for me:

    
     * Reorder product data tabs
     */
    add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
    function woo_reorder_tabs( $tabs ) {
    
        $tabs['description']['priority'] = 5;
        $tabs['specifications']['priority'] = 10;
        $tabs['reviews']['priority'] = 15;
    
        return $tabs;
    }
    
    /**
     * Remove product data tabs
     */
    add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
    
    function woo_remove_product_tabs( $tabs ) {
    
        unset( $tabs['additional_information'] );   // Remove the additional information tab
    
        return $tabs;
    }
    
    /**
     * Add a custom product data tab
     */
    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
    function woo_new_product_tab( $tabs ) {
        
        $tabs['specifications'] = array(
            'title'     => __( 'Specifications', 'woocommerce' ),
            'priority'  => 10,
            'callback'  => 'woo_new_product_tab_content'
        );
    
        return $tabs;
    
    }
    

    tabs
    Link to image: https://d.pr/i/zVuRzz

    Please let me know how that goes, or if you have any questions!

    Plugin Support Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please feel free to start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tabs re-order not working’ is closed to new replies.