我在WooCommerce中创建了两种自定义优惠券类型:
function custom_discount_type( $discount_types ) {
$discount_types['cash_back_fixed'] =__( 'Cash Back fixed discount', 'woocommerce' );
$discount_types['cash_back_percentage'] =__( 'Cash Back Percentage discount', 'woocommerce' );
return $discount_types;
}
add_filter( 'woocommerce_coupon_discount_types', 'custom_discount_type',10, 1);
Run Code Online (Sandbox Code Playgroud)
订单状态为"已完成"后,我想获得折扣类型,例如:
function wc_m_move_order_money_to_user( $order_id, $old_status, $new_status ){
if( $order->get_used_coupons() ) {
if ($coupon->type == 'cash_back_fixed'){
$coupons_amont = ???
....
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是$coupon->type不起作用.
如何获得订单中使用的优惠券类型?
我怎样才能获得原始优惠券金额?
谢谢