woocommerce_rest_order_actions_email_preferred_template_ids
Filter the preferred template IDs for auto-selecting an email template.
Template IDs earlier in the array are preferred. Only templates that are also in the available templates list will be considered.
Usage
add_filter( 'woocommerce_rest_order_actions_email_preferred_template_ids', 'wp_kama_woocommerce_rest_order_actions_email_preferred_template_ids_filter', 10, 3 );
/**
* Function for `woocommerce_rest_order_actions_email_preferred_template_ids` filter-hook.
*
* @param string[] $preferred_template_ids Ordered array of template IDs (most preferred first).
* @param WC_Order $order The order.
* @param string[] $available The available template IDs for this order.
*
* @return string[]
*/
function wp_kama_woocommerce_rest_order_actions_email_preferred_template_ids_filter( $preferred_template_ids, $order, $available ){
// filter...
return $preferred_template_ids;
}
- $preferred_template_ids(string[])
- Ordered array of template IDs (most preferred first).
- $order(WC_Order)
- The order.
- $available(string[])
- The available template IDs for this order.
Changelog
| Since 10.7.0 | Introduced. |
Where the hook is called
woocommerce_rest_order_actions_email_preferred_template_ids
woocommerce/src/Internal/Orders/OrderActionsRestController.php 410-415
$preferred_template_ids = apply_filters( 'woocommerce_rest_order_actions_email_preferred_template_ids', $default_preferred_ids, $order, array_map( fn( $t ) => $t->id, $available_templates ) );
Where the hook is used in WooCommerce
woocommerce/includes/emails/class-wc-email-customer-pos-completed-order.php 387
add_filter( 'woocommerce_rest_order_actions_email_preferred_template_ids', array( $this, 'add_to_preferred_template_ids' ), 10, 2 );
woocommerce/includes/emails/class-wc-email-customer-pos-refunded-order.php 459
add_filter( 'woocommerce_rest_order_actions_email_preferred_template_ids', array( $this, 'add_to_preferred_template_ids' ), 10, 2 );