0

Can anyone modify the following code with an if condition to do the followings:

if the tab named "uwa_auction_bids_history" exists then the reordering of the tabs to be done as is, but if it doesn't exist, only the first 2 tabs to be reordered ("description & additional_information" ) It should be a basic if/else condition to be added to this snippet but I have no php knowledge so I need a kind man's help...

Thanks!

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

    $tabs['description']['priority'] = 5;           // Reviews first
    $tabs['additional_information']['priority'] = 10;           // Description second
    $tabs['uwa_auction_bids_history']['priority'] = 15; // Additional information third

    return $tabs;
}

2 Answers2

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

    $tabs['description']['priority'] = 5;           // Reviews first
    $tabs['additional_information']['priority'] = 10;           // Description second
    if ($tabs[''] !== undefined)
    {
        $tabs['uwa_auction_bids_history']['priority'] = 15; // Additional information third
    }
    return $tabs;
}
0

Based on Slobodan's kind help I have adjusted the code to fit exactly my needs. Thanks Slobodan for your kind help! Problem Solved!

/**
 * Reorder product data tabs
 */
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
    if ($tabs[''] !== undefined)
    $tabs['description']['priority'] = 5;           // Description first
    $tabs['additional_information']['priority'] = 10;           // Details second
    {
    $tabs['description']['priority'] = 5;           // Description first
    $tabs['additional_information']['priority'] = 10;           // Details second      $tabs['uwa_auction_bids_history']['priority'] = 15; // Bids third      
    }
    return $tabs;
}