Normal behavior of Woocommerce is:
- If order is "pending" (Awaiting payment) it does not send a "New Order" email
- If order is "on Hold"(Awaiting confirmation) it sends "New Order" email.
- If order is immediately set from "Pending" to "Processing" (by payment gateway) - it sends "New Order" email.
I want to send "New Order" email only when order status reaches "Processing" (no mater the previous status)
So Ultimately the objective is to stop woocommerce from sending "New Order" email on order status "hold" and to make it send only (and always) when status gets to "Processing".
First I have tried WooCommerce send email notification to admin for specific order status answer code that works perfectly for successfully triggering the "New Order" email on order status "processing", however the email still gets send on order status "hold" (so sometimes it might be sent twice).
Trying to go around this by disabling the "New Order" email on "Hold" status by going to:
Admin >> Woocommerce >> Settings >> Emails
then disabling "New Order" order email by clicking manage button, does not work (this disabled the email entirely and it stops sending entirely even when triggered on processing by the above code)
Then I tried Disable WooCommerce New order email notification if order status is On hold answer code.
However it disables successfully the New Order email, but if the order goes from "On Hold" to "Processing" you don't get any email at all and if a new order is set directly to processing and you have the previous code for triggering the email then you also have the problem of receiving 2 emails. Switching the status from:
return $order->get_status() === 'on-hold' ? '' : $recipient;
to:
return $order->get_status() === 'processing' ? '' : $recipient;
disables the "New order" email entirely.
I basically wanted to document my struggle with this and share my current solution because there seems to be quite a few people with this same intention but no clear concise and actual functional way of doing it.