Trustpilot Afs 2

Hi All

I'm using TP to automate product reviews when a purchase has been completed however TP have updated their end of the system to AFS 2 and now require the email template they receive to contain a "structured data" snippet as below

This snippet gets stripped from the email template before sending. Is there anyone who can help with getting this code to remain in the email?
Thanks

Steve

What email editor do you use - old or new one?

It's the old one this site is version 4.3.9

Thanks

Could you please clarify how TP is connected with email in CS-Cart ?

Yes.

I've 'crudely' added a bcc to the Mailer.php file as TP now require the trigger to be sent via bcc

Then in functions/fn.cart.php if the order status is complete the TP email address is added to the bcc setting

Finally in the orders/invoice.tpl I've added the code above, it's getting stripped out though.

Many thanks

Steve

i''m surprised they want JS in an email versus simply encoding a string in the header or an html comment/link or pixel image. There is possibly a post-filter setup for email in cs-cart that is used to prevent the platform from being used as a spam generator or malware distributor (the JS might be being strpped out by the server). Would have to research that, but first I'd suggest you review the body of the mssages by temporarily diverting a copy of the message body to a file in send_mail_post hook to ensure that your data is actually there as sent to the Mailer.

How are you determining that it's being stripped and not being missed by your logic?

I was surprised too, they only provide support for Magento, Presta Shop and Wordpress....

If I remove the tags the content gets passed through to the email, which leads me to think the script tags are being removed somewhere in the process.

Thanks for commenting and offering help

Steve

If you want to contact me via my contact link in signuatre, I'd be happy to take a quick look for you and review what you've done for both your adding of BCC and your incorporation of the JS into the email.

Yes.

I've 'crudely' added a bcc to the Mailer.php file as TP now require the trigger to be sent via bcc

Then in functions/fn.cart.php if the order status is complete the TP email address is added to the bcc setting

Finally in the orders/invoice.tpl I've added the code above, it's getting stripped out though.

Many thanks

Steve

Are you sure that the correct template was changed? There are two invoice.tpl files

design/themes/responsive/mail/templates/orders/invoice.tpl

design/backend/mail/templates/orders/invoice.tpl

Yes, I've already customised the templates via my_changes and if the are removed the text between the tags comes through.

Just to let all know that I've resolved this

Adding {scripts}{/scripts} before the opening tag keeps the code there.

Thanks for all the help and suggestions, appreciated

Steve

I'm not aware of a 'scripts' tag. However, I am aware of the 'script' tag. Was this a typo?

It is normally used like this:

{script src="js/addons/google_analytics/google_analytics.js"}

Good to know that using this tag as a container can prevent post-filtering of template data. Did you find this documented somewhere or did you just happen upon it?

Also, did you try using 'literal' tags around non-template variable code?

No its not a typo and didn;t find the docs for it, I tried {literal} tags too.

{scripts} {/scripts} is in the default scripts.tpl file.

/design/themes/responsive/templates/common/scripts.tpl.

If you look it encapsulates all the {script src=""} tags. It was a shot in the dark as to whether that would help or not but as tags are present in CS Cart tpl files so I figured that they must be a way of doing it.

Steve

strange given that it is not referenced in the smarty documentation (nor the cs-cart docs) and I didn't find anywhere under the templates/addons directory structure that uses it.

Okay, always learn something new....

So your template code looks like?

{scripts}
  
{/scripts}

Oddly no. It looks like this

{scripts}{/scripts}
If I put my code in between the tags then the main js code is also added.

Okay, but that makes no sense to me. And to have an unnamed object defined also makes no sense... But glad it's working for you.

I've been having the same issue.

Adding the script tags before isn't working for me.

TrustPilot tell me it's the + within the which is being changed to when the email sends.

Any ideas please?

I am adding this into the invoice.tpl

Thanks

Andrew

Most likely this is because you are using an html editor (or the newer email editor) and it is escaping the data for security purposes.

Note that using a "script" tag in an email will fail at a significant number of email sites in that it is a large security risk and may mark your emails as SPAM.

If you're using the older smarty template emails, try putting the "application/json-trustpilot" into a variable and then using a nofilter modifier. I.e.

{assign var="script_type" value="application/json-trustpilot"}

If you're using the new email editor that uses TWIG, I don't know the equivalent to 'notilter' in TWIG.

I've tried that now and still no luck! Even after clearing the cache.

That's what I have in the editor, screenshot also attached. I've tried adding it in CS Cart through the template editor (version 4.3.2) and then through CPanel editors.
I also tried adding the variable as per your code.

Don't think you can effectively use smarty variables in any of the html editors. You will have to modify the template directly or utilize one of the hooks. But note that there is html filtering that is done on resulting template generation and I don't know if the 'script' tags will be preserved.