3

Ok this is my scenario, I have a single use coupon 12345, and two users A and B use the same coupon at same time. If User A has applies the coupon and is currently at the payment page, Woocommerce accepts the same coupon 12345 from user B and both transactions are succesfull.

Any way to prevent this?

de-bugged
  • 935
  • 4
  • 14
  • 34
  • which gateway ? when you say payment page is after checkout ? coupon use limit is defined to 1 ? – XciD Nov 28 '14 at 13:38
  • Paypal Express Payment gateway. By payment page I mean during payment when paypal ask for login details. Yes I have set coupon limit to 1. – de-bugged Nov 29 '14 at 02:35

1 Answers1

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();
}
XciD
  • 2,537
  • 14
  • 40