3

好的,这是我的场景,我有一张一次性优惠券 12345,两个用户 A 和 B 同时使用同一张优惠券。如果用户 A 已经申请了优惠券并且当前在支付页面,Woocommerce 接受来自用户 B 的相同优惠券 12345 并且两次交易都成功。

有什么办法可以防止这种情况?

4

1 回答 1

0

You can try this waiting for woocommerce to repair this bug :

// Hook after order creation and before going to payment page
add_action( 'woocommerce_checkout_order_processed' , 'increase_immediately_coupon', 10, 2);

function increase_immediately_coupon( $order_id, $received ){
    $order = new WC_Order( $order_id );

    $order->increase_coupon_usage_counts();
}

// Hook if gateway send and on-hold status
add_action( 'woocommerce_order_status_on-hold' , 'decrease_immediately_coupon', 10, 1);

function decrease_immediately_coupon( $order_id ){
    $order = new WC_Order( $order_id );

    $order->decrease_coupon_usage_counts();
}
于 2014-11-29T10:09:56.993 回答