Hook to use when customer placing order

WordPress Development Asked by Kevsterino on December 26, 2020

Currently I am using woocommerce_thankyou action to run a function that creates an order at a third party service.

However, sometimes customers don’t return to the Thank You page after visiting our Payment Service Provider, resulting in no order being created at the third party.

Would it be better to use the woocommerce_order_status_completed action? Any other hooks I could use? Is there a scheme/rundown available somewhere of all the actions that follow eachother? Any other ideas to solve this problem?

One Answer

If you want to send data to third party service, then you want to trust this connection.

So using Thank You page isn't the best idea.

There are some hooks that you may want to check and which of them will be the best for you depends on what exactly are you trying to achieve...

You can use:

  • woocommerce_new_order - it takes $order_id as first param and it's called whenever a new order is placed in WC.

  • woocommerce_order_status_<status> - it also takes $order_id as first param and it will be called when the order changes status to (you can use processing, completed and so on as ).

Answered by Krzysiek Dróżdż on December 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP