Skip to content

Email template displayed incorrectly when using depend inside an if #36438

@igi8819

Description

@igi8819

Preconditions and environment

  • Magento version: 2.4.5-p1
  • Magento version: 2.4.4-p2

Steps to reproduce

  1. Go to admin -> marketing -> email templates
  2. Click Add new email template
  3. Load Default Template form "New Order"

Add these lines before greeting/or wherever you want
{{if order_id}} {{depend order_id}} {{trans 'My order id is: <span class="no-link">%order_id</span>.' order_id=$order_id |raw}} {{/depend}} {{/if}}

So looks like this:

        {{if order_id}}
            {{depend order_id}}
            {{trans 'My order id is: <span class="no-link">%order_id</span>.' order_id=$order_id |raw}}
            {{/depend}}
        {{/if}}

        <p class="greeting">{{trans "%customer_name," customer_name=$order_data.customer_name}}</p>
  1. Save email template and go to stores -> configuration -> sales -> sales emails
  2. Add this new email template to "New Order Confirmation Template" than save it
  3. Clear cache
  4. Place and order in frontend and see the email content.
    image

The if condition is not processed.

I see that this in 2.4.5 (without p2) it is working.
Probably the issue is in the filter function, which is in the vendor/magento/framework/Filter/Template.php file

When i compare this with 2.4.5 version it way to different

2.4.5-p2
image

2.4.5
image

Expected result

if condition in email template processed correctly

Actual result

if condition in email template not processed correctly

Additional information

this issue also happening on Magento 2.4.4-p2

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions