cancel
Showing results for 
Search instead for 
Did you mean: 

How to include text depending on shipping and payment methods in transactional emails?

Highlighted

How to include text depending on shipping and payment methods in transactional emails?

I need to insert in my emails conditional texts depending on shipping and payment methods.

I know how to display shipping method code:

{{var order.getShippingMethod()}}

and payment code:

{{var order.getPayment().getMethodInstance().getCode()}}

There are conditional statements like "if" and "depend" available. But none of them offers comparison to a string, which is necessary to achieve what want. For example this does not work or I am doing it not right?

{{if order.getShippingMethod() == "storepickup"}}
    text1
{{else}}
    text2
{{/if}}

What I was able to do was to add a block that can display what I need

{{block type='core/template' area='frontend' template='custom/email/new/payment.phtml' order=$order}} 

but this way this text is defined outside the email template making maintenance complicated.

 

Is there a way to achieve what I need with existing functionality? Maybe I am able to add some custom variable or method I could use with conditional statement. How to do that?

 

 

1 REPLY 1
Highlighted

Re: How to include text depending on shipping and payment methods in transactional emails?

Hello @kathdroid 

 

{{block type='core/template' area='frontend' template='custom/email/new/payment.phtml' order=$order}} 

i am not sure what is issue with that

 

Using another way possible in order model you can extends and add new method

public function getShippingData()
{
 ..............................
}

and you can that method into email template 

 

hope it will help you. 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer