我真的很难让它发挥作用。我脑子里有一个想法:
能够通过常规优惠券选项卡中的额外字段将单个用户分配给优惠券代码,该字段将未分配的用户列出优惠券代码
我不想使用第三方扩展、自定义字段等。我希望我能够通过元数据做到这一点,但我失败了。不知道如何正确完成它。
在订单页面上添加两个额外的列并显示优惠券代码和分配给它的用户。
在 phpstorm 中阅读文档和 xDebugging 一段时间后,我也未能完成。
function order_sellers_and_coupons_columns_values($column)
{
global $post, $the_order;
if ($column == 'order_coupon_code') {
$coupons = $the_order->get_used_coupons(); // not sure how to get coupon object by the coupon code
echo (count($coupons)) ? $coupons[0] : '';
}
}
// even though I see the order objects have an items and coupon lines property,
// which is an object, i can't get access to it
$the_order->items["coupon_lines"]
Run Code Online (Sandbox Code Playgroud)
我不是要求现成的解决方案,而是向我展示如何完成它。
在此先感谢您的任何帮助。