Can someone helps me to understand the logic of WooCommerce for sending email on a completed order?

If I'm not wrong, the mail is send when the order is marked complete, but I'm not able to find the code that actually do it. All I can see is the action hook woocommerce_order_status_completed_notification that trigger the sending mechanism inside WC_Email_Customer_Completed_Order, but I don't know how that hook is used inside WooCommerce plugin... When and where is it trigger?



After some test and research, I think I've found where it is trigger. If I understood it correctly (this is simplistic approach of all functions and hooks used in process);

1) The Order is save (WC_Order->save())

2) The status set before is used to create an action hook ('woocommerce_order_status_completed')

3) Inside WC_Emails, ::send_transactional_email() is hooked to this action ('woocommerce_order_status_completed')

4) WC_Emails::send_transactional_email(), execute the action hook ('woocommerce_order_status_completed_notification') which is used to send an email.

Please tell me, if you see some misunderstanding about the process. Hopes it helps anybody looking for the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.