Add text to email template if order contains virtual product
-
12-12-2019 - |
Question
I am thinking of selling tickets using the virtual product function. Therefore I would like to add text to the email template only if an virtual product is present. Is this possible?
Solution
One of the easer way would be to include a pthml file to your email
Add code below to location where text to be display in your email template
{{block type='core/template' area='frontend' template='<module_name>/orderemail.phtml' order=$order}}
in your template file /orderemail.phtml
$_order = this->getOrder()
$hasVirtual = false;
$items = $order->getAllVisibleItems();
foreach($items as $i){
if( $i->->getIsVirtual()){
$hasVirtual = true;
}
}
if($hasVirtual){
echo 'text here
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange