I am having a custom module in which I created a custom email template where I am displaying the details of some the items and it's cost.
I am getting the details like,
//Details table rows as string
$dataDetails .= '<tr><td align="left" width="325" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;"><strong>' . $item['name'] . $this->getCustomOptionText($item) . '<br>sku: </strong>' . $item['sku']
. '</td><td align="right" width="325" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">' . $formatedPrice
. '</td><td align="right" width="325" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">' . $item['qty']
. '</td><td align="right" width="325" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">' . $rowTotal . '</td></tr>';
}
//detail totals as a table in string
$detail_footer = '<table>';
$detail_footer .= '<tr><td align="right" width="975" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" >SubTotal : </td><td> </td><td align="right" width="325" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" >' . $formattedsubTotal . '</td></tr>';
//Parametes the template email variable to send
$params = array(
'customer' => $customer,
'shippingTitle' => $shippingTitle,
'shippingAmount' => $shippingAmount,
'grandTotal' => $grandTotal,
'website' => $websiteName,
'dataDetails' => $quoteDetails,
'detail_footer' => $quote_footer,
);
I am sending the email below as,
$postObject = new \Magento\Framework\DataObject();
$postObject->setData($params);
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
try {
$transport = $this->_transportBuilder
->setTemplateIdentifier('details_email_template')
->setTemplateOptions(
[
'area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE,
'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
]
)
->setTemplateVars(['data' => $postObject])
->setFrom($this->scopeConfig->getValue(self::XML_PATH_EMAIL_SENDER, $storeScope))
->addTo($customerEmail, $customer)
->getTransport();
$transport->sendMessage();
$this->inlineTranslation->resume();
} catch (\Exception $e) {
$this->messageManager->addError(__('Sorry, we can\'t send the email right now.' . $e->getMessage()));
}
In my email template, I am calling the data_datils as,
<tbody>
{{trans "%dataDetails" dataDetails=$data.dataDetails}}
</tbody>
Here, I am receiving the email properly, however, the data_details received in the email is including the email tags.
In the email received the contents are like,
<table><tr><td align="right" width="975" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" >SubTotal : </td><td> </td><td align="right" width="325" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" >$330.00</td></tr><tr><td align="right" width="975" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" >Discount : </td><td> </td><td align="right" width="325" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" >$0.00</td></tr><tr><td align="right" width="975" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" >Shipping & Delivery ( Flat Rate - Fixed ) : </td><td> </td><td align="right" width="325" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" >$20.00</td></tr><tr><td align="right" width="975" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" ><strong>GrandTotal : </strong></td><td> </td><td align="right" width="325" style="font-size:13px;padding:5px 9px 6px 9px; line-height:1em;" ><strong>$350.00</strong></td></tr></table>
How can I exclude the HTML tags here and display only the values in the email? I have searched for it but could not find anything relevant.
I also tried using trim but this also couldn't give me the proper result,
trim(strip_tags($dataDetails))
Please, can anyone help?