亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 woocommerce 管理列表狀態和用戶方面顯示順序

在 woocommerce 管理列表狀態和用戶方面顯示順序

PHP
慕的地6264312 2023-10-15 14:39:17
在 woocommerce 管理端的訂單列表中,我想按狀態顯示訂單。我的意思是說,如果訂單處于處理狀態,則該訂單應顯示在管理訂單列表中,而其他訂單不應顯示在該列表中。檢查圖像以了解我需要的更多詳細信息..在此處輸入圖像描述
查看完整描述

1 回答

?
翻過高山走不出你

TA貢獻1875條經驗 獲得超3個贊

我猜你正在尋找這樣的東西?


/**

?* Limit statuses dropdown for custom user role.

?*

?* @param array $statuses

?* @see wc_get_order_statuses()

?*/

add_filter( 'wc_order_statuses', function( $statuses ) {

? ? # Custom user role (registered elsewhere).

? ? $custom_user_role = 'administrator';

? ??

? ? # Status(es) of orders to show to custom user role.

? ? $limit_to_order_statuses = array(

? ? ? ? 'wc-processing' => 1,

? ? ? ? 'wc-on-hold' => 1,

? ? );

? ??

? ? # Make sure we're editing right query.

? ? # If not, then nothing to change ("return early").

? ? if (

? ? ? ? !function_exists( 'get_current_screen' )

? ? ? ? ||? 'shop_order' !== get_current_screen()->post_type

? ? ? ? || 'woocommerce' !== get_current_screen()->parent_base

? ? )

? ? ? ? return $statuses;

? ??

? ? # Check if user has the specified custom user role.

? ? # If they don't, then nothing to change ("return early").

? ? if ( !in_array( $custom_user_role, wp_get_current_user()->roles ) )

? ? ? ? return $statuses;

? ??

? ? return array_intersect_key( $statuses, $limit_to_order_statuses );

} );


查看完整回答
反對 回復 2023-10-15
  • 1 回答
  • 0 關注
  • 114 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號