How to add custom code to prestashop

2019-09-05 04:58发布

I am trying to add the following code to my prestashop site to be able to display my google trusted site badge:

<!-- BEGIN: Google Trusted Stores -->
<script type="text/javascript">
  var gts = gts || [];

  gts.push(["id", "STORE_ID"]);
  gts.push(["badge_position", "BOTTOM_RIGHT"]);
  gts.push(["locale", "english_australia"]);
  gts.push(["google_base_offer_id", "ITEM_GOOGLE_SHOPPING_ID"]);
  gts.push(["google_base_subaccount_id", "ITEM_GOOGLE_SHOPPING_ACCOUNT_ID"]);
  gts.push(["google_base_country", "ITEM_GOOGLE_SHOPPING_COUNTRY"]);
  gts.push(["google_base_language", "ITEM_GOOGLE_SHOPPING_LANGUAGE"]);

  (function() {
    var gts = document.createElement("script");
    gts.type = "text/javascript";
    gts.async = true;
    gts.src = "https://www.googlecommerce.com/trustedstores/api/js";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(gts, s);
  })();
</script>
<!-- END: Google Trusted Stores -->

i need it to be visible on every page and no matter what i do, i cant get it to display the badge.

3条回答
唯我独甜
2楼-- · 2019-09-05 05:12

The simplest way is to insert your code in header.tpl.

查看更多
一纸荒年 Trace。
3楼-- · 2019-09-05 05:13

It's a little bit late, but the easiest way is to create a js file, and put it in your theme script folder : /themes/yourtheme/js/autoload That way it's loaded on every pages.

查看更多
你好瞎i
4楼-- · 2019-09-05 05:14

most likely you need installing a module to add custom html.
here is one to add on the bottom/footer area.
http://www.prestashop.com/forums/topic/165066-free-prestashop-module-easy-footer/
you can add custom html content on footer area and it will be visible to whole website.

查看更多
登录 后发表回答