• Resolved amihaidany

    (@amihaidany)


    Hello,

    I have a coupon with a limit of 1 use per customer.
    If a logged in customer applies the coupon, and goes to the payment gateway, but didn’t complete the purchase – if order is not paid and cancelled, the coupon will still be counted as used.

    Even when deleting the cancelled order, in order to ‘delete’ the count of usage for that customer – the usage count is not reset.

    How can i bypass, or change this behavior?

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support tijosh

    (@tijosh)

    Hi there @amihaidany,

    The best way to get around this would be to use an on-site payment gateway for payments. This would not create an order (and thus use the coupon) if someone abandons the purchase without checking out.

    We have a list of on-site payment gateways here.

    Hope this helps!

    Thread Starter amihaidany

    (@amihaidany)

    Hello,

    Thank you for your reply! However, we DO need that payment gateway.

    I’ve started to work on a workaround – to release any held coupons. With this snippet, “pending payments” order will not count the coupon as used by the user – only when being “processed”.

    function release_held_coupons_for_unpaid_orders( $order_id ) {
    	if ( ! $order_id ) {
    		return;
    	}
    
    	$order = wc_get_order( $order_id );
    	$order->get_data_store()->release_held_coupons( $order, true );
    
    }
    add_action( 'woocommerce_new_order', 'release_held_coupons_for_unpaid_orders', 999 );
    

    What do you think?

    Thanks!

    • This reply was modified 4 years, 3 months ago by amihaidany.
    Plugin Support tijosh

    (@tijosh)

    Hi there @amihaidany,

    A recent update to WooCommerce addresses this question and releases coupon holds for cancelled orders. You can read more about it here.

    I’ll go ahead and close this thread also. If you have another question, feel free to open a new topic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Coupon limit per user – orders count even when deleted or not paid’ is closed to new replies.