So currently when the payment fails, Woo-commerce puts the order to failed status. And if you reload or do a hard refresh and go-to checkout again without changing the cart you still have to do the payment for that failed order. I don't want that to happen. I want to create a new order with same cart and checkout details.(My invoice printing plugin makes 2 invoices with one failed and one completed if the payment approved which makes confusion on packaging dept.)
I tried few of the checkout hooks but none of them works.like
woocommerce_checkout_order_processed
woocommerce_review_order_after_payment
woocommerce_pay_order_before_submit
As the payment plugin makes a ajax call I am not sure which hook to use. Or how to do a hard reload so that it will skip the failed order and do a new order again. Thanks for reading and any info will be helpful. :)
You can use the
woocommerce_checkout_order_createdhook, which is starting when a new order is created, to create a new order when a payment fails. You will need to check if the current order is in an "Error" status, and if so, create a new order using the data from the previous order.Or use
woocommerce_payment_failedhook: