Closed manaftryzens closed 1 year ago
@manaftryzens You can use
{% raw %}{{var order.increment_id}}{% endraw %}
to preserve the Magento tags in the processed html content.
When we request campaign content for a template you have mapped in Magento, we use the endpoint https://region-api.dotdigital.com/v2/campaigns/{id}/prepared-for-transactional-email/anonymouscontact@emailsim.io. Storing only the processedHtmlContent
ensures that unsupported tags (like unsubscribe blocks) are removed, to prevent transactional email being used for marketing purposes.
See also https://support.dotdigital.com/hc/en-gb/articles/212214408-Using-transactional-email.
Hope this helps.
Dotdigitalgroup\Email\Model\Email\Template::saveTemplate() - This function is being called periodically to update Magento OOTB transactional emails by pulling the contents from corresponding email campaigns are Dotdigital dashboard.
This function finally updates the email template with $template->setTemplateText($dmCampaign->processedHtmlContent) content. But the output of $dmCampaign->processedHtmlContent is actually a plain html text after removing all the magento specific email template variables like {{var order.increment_id}}
So if we have an email campaign at Dot digital with the below content for example,
Customer Name - {{var order.getCustomerFirstname()}} {{var order.getCustomerLastname()}} Order Reference - {{var order.increment_id}} Order Items - {{layout handle="sales_email_order_items" order=$order area="frontend"}}
Then the magento template is updated as below
Customer Name - Order Reference - Order Items -
When we checked the API call, the output of $dmCampaign = $client->getCampaignByIdWithPreparedContent($campaignId); (This is executed at Dotdigitalgroup\Email\Model\Email\Template::syncEmailTemplate()) method contains the below properties in it
$dmCampaign->htmlContent = This property contains the real html content including the magento variables as it is. $dmCampaign->plainTextContent = This property also contains the real html content including the magento variables as it is. $dmCampaign->processedPlainTextContent = This property also contains the html content including the magento variables as it is. $dmCampaign->processedHtmlContent = This property contains the html content , but after removing the magento variables with blank space
If we replace $template->setTemplateText($dmCampaign->processedHtmlContent) with $template->setTemplateText($dmCampaign->htmlContent), we will get an expected result.
But I am not sure if this is a defect or it is purposefully done to avoid any unwanted code injection. Can you please check if this?
If this needs a fix, please check the PR below.
https://github.com/dotmailer/dotmailer-magento2-extension/pull/595