I am stuck in the email sending system of WooCommerce WordPress

My functions.php:

add_filter('woocommerce_email_classes', 'add_custom_order_status_emails');

function add_custom_order_status_emails($emails) {

$emails['WC_Email_Customer_Doi_Xac_Nhan_Order'] = include get_stylesheet_directory() . '/woocommerce/emails/class-wc-email-customer-doi-xac-nhan-order.php';

`$email_admin = include get_stylesheet_directory() . '/woocommerce/emails/class-wc-email-admin-da-cap-nhat.php';`

`$email_customer = include get_stylesheet_directory() . '/woocommerce/emails/class-wc-email-customer-da-cap-nhat.php';`

`$emails['WC_Email_Admin_Updated'] = $email_admin;`

`$emails['WC_Email_Customer_Updated'] = $email_customer;`
return $emails;

}

add_action('woocommerce_order_status_changed', 'trigger_custom_order_email', 10, 4);

function trigger_custom_order_email($order_id, $old_status, $new_status, $order) {

if ($new_status === DOI_XAC_NHAN) {

    `WC()->mailer()->emails['WC_Email_Customer_Doi_Xac_Nhan_Order']->trigger($order_id);`
}

`if ($new_status === DA_CAP_NHAT) {`

    `WC()->mailer()->emails['WC_Email_Admin_Updated']->trigger($order_id);`

    `WC()->mailer()->emails['WC_Email_Customer_Updated']->trigger($order_id);`

`}`
}

theme-child structure

/woocommerce

    /emails

        - admin-new-order.php

        - admin-updated-status.php

        - class-wc-email-admin-da-cap-nhat.php

        - class-wc-email-customer-da-cap-nhat.php

        - class-wc-email-customer-doi-xac-nhan-order.php

        - customer-awaiting-confirmation.php

        - customer-updated-status.php

    /plain

The issue I’m facing is that when I call trigger() to send emails, the second email gets sent but it doesn’t have any CSS. I already checked under WooCommerce → Settings → Emails → Template, and my custom email templates all display the correct layout. I’ve asked ChatGPT and Cursor, but I still haven’t been able to fix it.

And when I switched the order of these two lines, the admin email was no longer sent to the admin:

if ($new_status === DA_CAP_NHAT) {

$email_customer = WC()->mailer()->emails['WC_Email_Customer_Updated'];

$email_admin = WC()->mailer()->emails['WC_Email_Admin_Updated'];

}

My code:

file class-wc-email-admin-da-cap-nhat.php https://textdoc.co/NJPtjVHWwc1RCoyX

file template admin-updated-status.php

https://textdoc.co/WBfPAaELgC9JKGuh

file class-wc-email-customer-da-cap-nhat.php

https://textdoc.co/tEYw4TpK9HSzZ7Gy

file template customer-updated-status.php

https://textdoc.co/KH04c6RbTdB2IMre

Link Image:
email for admin: https://postimg.cc/QH6X4KCN
enter image description here

email for customer: https://postimg.cc/06SPytfr
enter image description here