Hooks for sending emails
An action that runs after each email sent to a customer, and a filter for the number of orders one bulk send handles. This article describes both, with an example of each.
After an email is sent
| Action | Arguments | Runs |
|---|---|---|
hpwe_email_sent |
WC_Order $order, WP_Post $template |
After an email from a template went to an order’s customer and was recorded on the order, for single and bulk sends. |
It does not run for previews, test emails or sends that failed.
This example keeps the name of the last template sent in the order’s own data, where another plugin or a report can read it:
add_action( 'hpwe_email_sent', function ( $order, $template ) {
$order->update_meta_data( '_my_last_order_email', $template->post_title );
$order->save();
}, 10, 2 );
Orders per bulk send
| Filter | Arguments | Controls |
|---|---|---|
hpwe_bulk_send_limit |
int $limit |
How many of the selected orders one run of the bulk action sends to. The default is 50. |
Keep the number low enough for a run to finish within your server’s time limit for a request. The notice after a run uses the same number.
add_filter( 'hpwe_bulk_send_limit', function () {
return 20;
} );
Put the code in a small custom plugin or in your child theme’s functions.php file, as with the filters in Adding your own placeholder tags.