1
votes

Just trying to stop checkout form stay still after checkout form submit complete. As we know WooCommerce checkout form submission done by ajax ?wc-ajax=checkout. As default after successfully complete an order checkout form redirect to thankyou page but that not what I want to do.

I want after after successfully complete an order checkout form stay still. I will redirect later after done some my own ajax or coding.

I look WooCommerce checkout.js didn't find any hook or anything to do that, So here I am to ask you guys to know anyone how to do this?

NOTE: My main reason to do this, after order status and payment status before checkout gone to thankyou page but for that I need order id and that's why it need to complete first. hope it make sense.

If you have quest feel free to ask.

1
I did something similar by overriding checkout.jsAkhtarujjaman Shuvo
Can't do that, I'm building a free plugin so can't do that. Need proper way.mlimon
You can do it. Just dequeue it and enqueue again inside your plugin. You must have to update when WooCommerce updates the checkout.jsAkhtarujjaman Shuvo

1 Answers

2
votes

The woocommerce_payment_complete hook is fired when the payment is completed. The only variable passed is the order id, though from that you can get the order object, and ultimately the user.

add_action( 'woocommerce_payment_complete', 'so_payment_complete' );
function so_payment_complete( $order_id ){
    $order = wc_get_order( $order_id );
    $order->update_status( 'pending' );
    $user = $order->get_user();
    if( $user ){
        // do something with the user
    }
}