目前,我正在构建一个插件,我需要添加一个操作按钮,以便打印带有管理命令的pdf。
如何通过我的插件向WooCommerce管理订单页面添加其他操作?
1 个回复
SO网友:Kaperto
您可以使用此代码在管理订单页面上添加操作:
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
//...
});
结束