Skip to main content
1 of 5
Ajwad Syed
  • 1.6k
  • 30
  • 63

M2 | How can we print array values in custom html email template by looping?

I want to print multiple coupon/gift codes in custom email template. I am getting single code as:

$templateVars = array( 'store' => $this->storeManager->getStore(), 'customer_name' =>$name, 'giftcods' => 'VFDFRVXSW43VF' ); 

In HTML Template file:

<div style="color:#696969;font-size:20px;text-align:center;"> <strong>{{var giftcods|raw}}</strong> </div> 

And output as:

enter image description here

But this is single code, I want print multiple codes in email. I have gone by some related links like:

Magento 2 : How to handle array values in custom email templates?

Pass Variable And Output In Custom Email Template

But there is no proper solution available specially about how to deal with array value in HTML template.

Ajwad Syed
  • 1.6k
  • 30
  • 63