如何将自定义代码添加到prestashop

How to add custom code to prestashop

本文关键字:添加 prestashop 代码 自定义      更新时间:2023-09-26

我正在尝试将以下代码添加到我的prestashop网站,以便能够显示我的谷歌信任网站徽章:

<!-- 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 -->

我需要它在每一页上都可见,无论我做什么,我都无法让它显示徽章。

很可能

你需要安装一个模块来添加自定义html.
这是一个要添加到底部/页脚区域.
http://www.prestashop.com/forums/topic/165066-free-prestashop-module-easy-footer/您可以在页脚区域添加自定义HTML内容,它将对整个网站可见。

有点晚了,但最简单的方法是创建一个 js 文件,并将其放在您的主题脚本文件夹中:/themes/yourtheme/js/autoload这样它就会加载到每个页面上。

最简单的方法是在 header.tpl 中插入代码。