I am looking for a hook which will be triggered after someone submit checkout form and order placed ( no matter he made the payment or not ) .
I tried woocommerce_new_order
But it’s not working.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Try woocommerce_thankyou hook. This will trigger after recieving order successfully, no matter how user made payment.
$hook_to = 'woocommerce_thankyou';
$what_to_hook = 'wl8OrderPlacedTriggerSomething';
$prioriy = 111;
$num_of_arg = 1;
add_action($hook_to, $what_to_hook, $prioriy, $num_of_arg);
function wl8OrderPlacedTriggerSomething($order_id){
//do something...
}
For more reference dig into woocommerce/templates/checkout/thankyou.php
Method 2
I found the solution. An old order already exists in my order list. So when I am adding new items in order, woocommerce just updating my old unpaid order. So I use woocommerce_resume_order action too. Now it’s fine.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0