Strict mode – Email Template

From Magento 2.3.4+, the Magento team added a new attribute for an email template, there is a strict mode or a legacy mode.

If you add a new email template for sales objects (orders, invoices, shipments) from the backend, then it might not works property. Example order items grid is not shown in an email. Because they don’t allow us to pass kinds of objects to a template (a block or a layout handle). Only array or scalar variables are allowed

You can see on the file \Magento\Framework\Filter\VariableResolver\StrictResolver – Function resolve

if (isset($stackArgs[$last]['variable'])
             && (is_scalar($stackArgs[$last]['variable']) || is_array($stackArgs[$last]['variable']))
         ) {
             // If value for construction exists set it
             $result = $stackArgs[$last]['variable'];
         }

All new emails are created from backend will have strict mode as a default, no changes to modify it on the backend. You have to change it via database management. Pls find email template data in the table email_template, then change field ‘is_legacy” to be 1.

Leave a Reply

Your email address will not be published. Required fields are marked *