Sometimes you might need to notify a third party when an order is processed on your WooCommerce store. Fortunately, doing so is quite easy when you use the hooks available.
Creating the Function
Firstly, we want to hook into the action that is triggered when an order is set to processing on our store. This is the point at which payment has been accepted and paid for (if applicable). You’ll need to add the following functions to your theme’s functions.php file.
* Notification on order pending to processing status change
Again, a fairly simple function. We’re using the wc_get_template_html() function to generate our email content, so this makes things a lot easier. Let’s take a look at the parameters for wc_get_template_html():
We’re passing the path to the customer-processing-order.php template file. You could create a woocommerce/emails folder in your own theme and duplicate any of the email templates from wp-content/plugins/woocommerce/templates/emails with a new name. This will allow you to create your own template for this email.
The second parameter is an array of arguments. We’re passing in the $order object, the $heading, the $mailer object, a sent_to_admin flag, and a plain_text flag. The heading is displayed at the top of the email with larger typography. We can modify the $heading of the email by passing in a different string of text in our iconic_processing_notification() function, at the $content variable. Currently we just use the subject line as a heading.
This should get you on your way. Now you can create your new email template and use the functions above to send the email. Comments below, as usual!