Home Forums WoodMart support forum wd_custom_tab priority

wd_custom_tab priority

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #572334

    FreeRiderNSK
    Participant

    Hello!
    How to change the tab “wd_custom_tab” priority correctly if it is applied to a product?
    I did this but got an error in the “query monitor” plugin:

    add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
    function woo_reorder_tabs( $tabs ) {
    	$my_tab = $tabs['wd_custom_tab']['title'];
    	if ( !empty($my_tab) ) {
     
    	$tabs['wd_custom_tab']['priority'] = 45;			// Кастомная вкладка товара первая
     
    	return $tabs;
    	} else {
    	return $tabs;
    	}
    }

    How to do it right?

    • This topic was modified 1 month, 1 week ago by FreeRiderNSK.
    • This topic was modified 1 month, 1 week ago by FreeRiderNSK.
    #572409

    Luke Nielsen
    Keymaster

    Hello,

    Try to use the code below instead of yours. Define the code in the functions.php file in your child theme.

    /**
     * Reorder product data tabs
     */
    add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
    function woo_reorder_tabs( $tabs ) {
    
    	$tabs['reviews']['priority'] = 5;			// Reviews first
    	$tabs['description']['priority'] = 10;			// Description second
    	$tabs['additional_information']['priority'] = 15;	// Additional information third
    
    	// Custom Tabs are from Product Settings
    	// $tabs['wd_custom_tab']['priority'] = 2; 
    	// $tabs['wd_custom_tab_2']['priority'] = 3;
    
    	// Additional Tabs are from Theme Settings
    	// $tabs['wd_additional_tab']['priority'] = 4;
    	// $tabs['wd_additional_tab_2']['priority'] = 5;
    
    	return $tabs;
    }

    Kind Regards

    #572599

    FreeRiderNSK
    Participant

    Hi!
    I wouldn’t write to you just like that.
    This causes a bug if the product doesn’t have “wd_custom_tab”.
    But then the second tab is not active by default, you need to click on it.
    I need “wd_custom_tab” first when it is filled in for the product!
    Please see screenshot.

    PS
    To make it work the way I want, I have to change the priority in the file.
    \woodmart\inc\integrations\woocommerce\functions.php

    I need a code with a condition. For function.php child theme.
    If “wd_custom_tab” is filled, then change the priority to 1.

    Attachments:
    You must be logged in to view attached files.
    #572860

    Luke Nielsen
    Keymaster

    Hello,

    Try to use the code below in this case:

    /**
     * Reorder product data tabs
     */
    add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
    function woo_reorder_tabs( $tabs ) {
    
    	$tabs['reviews']['priority'] = 5;			// Reviews first
    	$tabs['description']['priority'] = 10;			// Description second
    	$tabs['additional_information']['priority'] = 15;	// Additional information third
    
    	if ( !empty($tabs['wd_custom_tab']) ) {
                   $tabs['wd_custom_tab']['priority'] = 2; 
            }
    
    	return $tabs;
    }

    Kind Regards

Viewing 4 posts - 1 through 4 (of 4 total)