3

I like to use differrent text for order_update email template.

Admin->Marketing->Email template i create new template for "order update"

If $order.getStatusLabel() == "Cancel" I like to add some custom text. How to add $order.getStatusLabel() == "Cancel" in if condition or {{depend}}.

I used if condition in enter image description here

but my result getting:

enter image description here

Please let me know

Thank you.

0

2 Answers 2

1

You can use block like below

{{block class='Magento\\Framework\\View\\Element\\Template' 
area='frontend' template='Vendor_Module::email/order_update/statusinfo.phtml' order=$order}}

Then Create a custom template file and add below condition

<?php if($this->getData('order')->getStatusLabel() == 'Canceled') {
        echo "<p>Order status is cancel</p>"; 
      } else {
            echo "<p>Order status is not cancel</p>";
       }

?>
9
  • we can't directly use in Admin->Marketing->Email template-> "edit"->"Template Content" box?
    – Priya
    Mar 16, 2019 at 7:00
  • Hi you can use by update in sales email configuration settings. Create a template in Admin->Marketing->Email template (for example template name is "custom order update") then go to store->configuration->sales->sales email->Order Comments (which is may be use for order update email)->select your template in "Order Comment Email Template". Mar 16, 2019 at 7:36
  • Yeah that i selected. only i need to insert "if condition" in my "custom order update" in my email template.
    – Priya
    Mar 16, 2019 at 7:40
  • I also check that "if condition" is not working and i personally tested my code and it working well. you just need to update correct email template by guest and current theme. like in default it use (order update Magento/luma) and configure it in configuration settings Mar 16, 2019 at 7:54
  • Hi @Amith, Please check my updated question on top.
    – Priya
    Mar 16, 2019 at 9:12
0

Try below condition, It may help.

{{if $order.getStatusLabel()=='Canceled'}}

     <strong>CANCELED - THERE, ARE YOU HAPPY?!</strong>

{{else}}

     {{var $order.getStatusLabel() }}

{{/if}}
3
  • No it's not working.
    – Priya
    Mar 16, 2019 at 6:57
  • @mohana, I have edited my code, Try it again if it works Mar 16, 2019 at 7:14
  • No, it's also not working.
    – Priya
    Mar 16, 2019 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.