移除WooCommerce后台订单列表中的特定批量操作
移除WooCommerce订单列表批量操作的解决方案
你需要移除的几个批量操作对应的键名如下,直接添加到现有代码中即可:
export_xlsx→ Export as XLSXmark_exported→ Mark Exportedunmark_exported→ Unmark Exportedduplicate_order→ Duplicate
修改后的完整代码:
add_filter( 'bulk_actions-edit-shop_order', 'custom_shop_order_bulk_actions', 999 ); function custom_shop_order_bulk_actions( $actions ) { // 移除不需要的批量操作 unset( $actions['mark_on-hold'], $actions['invoice'], $actions['export_xlsx'], $actions['mark_exported'], $actions['unmark_exported'], $actions['duplicate_order'] ); return $actions; }
小提示:如果键名不匹配怎么办?
如果上述键名无效,你可以临时在函数里添加打印语句,查看所有批量操作的实际键名:
add_filter( 'bulk_actions-edit-shop_order', 'custom_shop_order_bulk_actions', 999 ); function custom_shop_order_bulk_actions( $actions ) { // 打印所有批量操作键名(使用完记得删除) echo '<pre>'; print_r($actions); echo '</pre>'; unset( $actions['mark_on-hold'], $actions['invoice'], $actions['export_xlsx'], $actions['mark_exported'], $actions['unmark_exported'], $actions['duplicate_order'] ); return $actions; }
刷新订单列表页面就能看到所有批量操作的键值对,找到对应操作的键名替换即可。
内容的提问来源于stack exchange,提问作者AlexTSF
相关产品推荐
相关产品推荐

