Skip to content

Instantly share code, notes, and snippets.

@cleytonmessias
Created February 12, 2014 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleytonmessias/8965062 to your computer and use it in GitHub Desktop.
Save cleytonmessias/8965062 to your computer and use it in GitHub Desktop.
Script de instalação do trustvox na NuvemShop
<script type="text/javascript">
var _trustvox = _trustvox || [];
_trustvox.push(['_storeId', '1']);
_trustvox.push(['_productId', "{{ product.id }}"]);
_trustvox.push(['_productName',"{{ product.name }}"]);
_trustvox.push(['_productPhotos', ["{{ product.featured_image | product_image_url('original') }}"]]);
(function() {
var tv = document.createElement('script'); tv.type = 'text/javascript'; tv.async = true;
tv.src = '//trustvox-production-assets.s3.amazonaws.com/assets/trustvox.1.min.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tv, s);
})();
</script>
@lombo
Copy link

lombo commented Feb 13, 2014

The gist will change as you will run it from inside a .js file(i'll send the details by email). The file should have this snippet:

  window._trustvox = window._trustvox || [];
  window._trustvox.push(['_storeId', "" + LS.store.id]);

  if(LS.product) {
    window._trustvox.push(['_productId',  "" + LS.product.id]);
    window._trustvox.push(['_productName',  LS.product.name]);
    //You have to parse de HTML to get the images. Problematic as stores have different HTML structure
    window._trustvox.push(['_productPhotos', []]);
  }

(function() {
    var tv = document.createElement('script'); tv.type = 'text/javascript'; tv.async = true;
    tv.src = '//trustvox-production-assets.s3.amazonaws.com/assets/trustvox.1.min.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tv, s);
  })();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment