您可以使用此代码在管理订单页面上添加操作:
const CUSTOM_ACTION_CODE = "my-plugin__custom-action-code";
add_filter("woocommerce_order_actions", function ($actions) {
$actions[CUSTOM_ACTION_CODE] = "label of the custom action";
return $actions;
});
add_action("woocommerce_order_action_" . CUSTOM_ACTION_CODE, function (\\WC_Order $order) {
// here the code of the treatement of $order
//...
});