Skip to main content
1 of 3
Dhaduk Mitesh
  • 1.7k
  • 1
  • 13
  • 29

Please add this to PHP file.

$giftcods = ['code1' => 'VFDFRVXSW43VF', 'code2' => 'FFRFRFVSW43VF', 'code3' => 'VFDFGFGFXSW43VF']; $templateVars = new \Magento\Framework\DataObject(); $templateVars->setData([ 'store' => $this->storeManager->getStore(), 'customer_name' => $name, 'giftcods' => new \Magento\Framework\DataObject($giftcods) ]); 

And set in template as ->setTemplateVars(['templateVars' => $templateVars])

Use variable in HTML as,

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

Clear cache: php bin/magento cache:clean and check it.

Dhaduk Mitesh
  • 1.7k
  • 1
  • 13
  • 29