Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Trustpilot Afs 2 Rate Topic   - - - - -

 
  • boxed-blue
  • Junior Member
  • Members
  • Join Date: 15-Apr 11
  • 53 posts

Posted 12 October 2017 - 08:55 AM #1

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

 

<script type="application/json+trustpilot">

{
 "recipientName": '{$order_info.firstname}',
 "recipientEmail": '{$order_info.email}',
 "referenceId": '{$order_info.order_id}'
}
</script>
 
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

CS Cart Design, Development and Hosting

This Is Kode - http://thisiskode.com

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 14,923 posts

Posted 12 October 2017 - 01:05 PM #2

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия

 
  • boxed-blue
  • Junior Member
  • Members
  • Join Date: 15-Apr 11
  • 53 posts

Posted 12 October 2017 - 01:06 PM #3

It's the old one this site is version 4.3.9

 

Thanks


CS Cart Design, Development and Hosting

This Is Kode - http://thisiskode.com

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 14,923 posts

Posted 12 October 2017 - 01:21 PM #4

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия

 
  • boxed-blue
  • Junior Member
  • Members
  • Join Date: 15-Apr 11
  • 53 posts

Posted 12 October 2017 - 04:38 PM #5

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


CS Cart Design, Development and Hosting

This Is Kode - http://thisiskode.com

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 9,884 posts

Posted 12 October 2017 - 06:43 PM #6

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?


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • boxed-blue
  • Junior Member
  • Members
  • Join Date: 15-Apr 11
  • 53 posts

Posted 12 October 2017 - 08:11 PM #7

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

 

If I remove the <script> 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


CS Cart Design, Development and Hosting

This Is Kode - http://thisiskode.com

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 9,884 posts

Posted 12 October 2017 - 10:34 PM #8

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 14,923 posts

Posted 13 October 2017 - 06:05 AM #9

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия

 
  • boxed-blue
  • Junior Member
  • Members
  • Join Date: 15-Apr 11
  • 53 posts

Posted 13 October 2017 - 07:45 AM #10

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


CS Cart Design, Development and Hosting

This Is Kode - http://thisiskode.com

 
  • boxed-blue
  • Junior Member
  • Members
  • Join Date: 15-Apr 11
  • 53 posts

Posted 13 October 2017 - 05:38 PM #11

Just to let all know that I've resolved this

 

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

 

Thanks for all the help and suggestions, appreciated

 

Steve


CS Cart Design, Development and Hosting

This Is Kode - http://thisiskode.com

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 9,884 posts

Posted 13 October 2017 - 06:44 PM #12

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? 


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • boxed-blue
  • Junior Member
  • Members
  • Join Date: 15-Apr 11
  • 53 posts

Posted 14 October 2017 - 10:08 AM #13

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 <script> tags are present in CS Cart tpl files so I figured that they must be a way of doing it.

 

Steve


CS Cart Design, Development and Hosting

This Is Kode - http://thisiskode.com

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 9,884 posts

Posted 14 October 2017 - 07:12 PM #14

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}
  <script type="text/tavascript">
    var = "this is my js code";
  </script>
{/scripts}

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • boxed-blue
  • Junior Member
  • Members
  • Join Date: 15-Apr 11
  • 53 posts

Posted 15 October 2017 - 08:30 AM #15

Oddly no. It looks like this

 

{scripts}{/scripts}
<script type="application/json+trustpilot">
{
  "recipientName": "{$order_info.firstname}",
  "recipientEmail": "{$order_info.email}",
  "referenceId": "{$order_info.order_id}"
}
</script>
 
If I put my code in between the tags then the main js code is also added. 

CS Cart Design, Development and Hosting

This Is Kode - http://thisiskode.com

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 9,884 posts

Posted 15 October 2017 - 01:40 PM #16

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.