Snippets
Here we provide snippets for you to place in your theme's functions.php.
Disclaimer: The code in this article is considered a site-specific customization. We provide the hooks and share the how-tos, but fixes or guarantees for this type of customization aren’t included in our standard support.
For help with setup, feel free to reach out for a consultation.
Snippet 1: Enable/Disable specific elements in selected email template
add_filter( 'yaymail_element_available_email_ids', function( $available_email_ids, $element ) {
if ( 'order_details_download' === $element->get_type() ) {
$available_email_ids[] = \YayMail\Emails\CustomerInvoice::get_instance()->get_id();
}
return $available_email_ids;
}, 10, 2 );
Below is the list of corresponding name variables:
New order: NewOrder
Cancelled order: CancelledOrder
Failed order (Admin): FailedOrder
Failed order (Customer): CustomerFailedOrder
Processing order: CustomerProcessingOrder
Order on-hold: CustomerOnHoldOrder
Completed order: CustomerCompletedOrder
Refunded order: CustomerRefundedOrder
Order details: CustomerInvoice
Customer note: CustomerNote
Reset password: CustomerResetPassword
New account: CustomerNewAccount
Alternatively, instead of using $available_email_ids[] = \YayMail\Emails\CustomerInvoice::get_instance()->get_id();
, you can replace it with $available_email_ids[] = wc_email_id;
Below is the list of variables:
new_order
cancelled_order
failed_order
customer_failed_order
customer_on_hold_order
customer_processing_order
customer_completed_order
customer_refunded_order
customer_invoice
customer_note
customer_reset_password
customer_new_account
Last updated
Was this helpful?