任何人都可以使用if条件修改以下代码以执行以下操作:
如果名为“uwa_auction_bids_history”的选项卡存在,那么选项卡的重新排序将按原样完成,但如果它不存在,则只需要重新排序的前两个选项卡(“description&additional_information”)它应该是基本的if /要添加到此片段的其他条件,但我没有PHP知识,所以我需要一个善良的人的帮助...
谢谢!
/**
* 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;
}
/**
* 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;
}
基于Slobodan的帮助,我调整了代码以满足我的需求。感谢Slobodan的帮助!问题解决了!
/**
* 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;
}