将javascript添加到Prestashop 1.6的最佳方法是什么?

时间:2018-02-23 13:09:25

标签: prestashop prestashop-1.6

我有一个非常奇怪的问题。我创建了一个模块,它将javascript代码添加到head和codeis显示。这是Google的商家评论。当客户支付产品费用时,此代码应显示带有问题的弹出窗口。我创建了一个if条件,只在付款模块之后显示此代码。但没有显示任何内容。也许我的问题是如何做到的?

 public function hookDisplayHeader() {
        if (Tools::getValue('id_order') != 0) {
            //$this->context->controller->addJS($this->_path . 'views/js/platform.js?onload=renderOptIn');

            $date = new DateTime('+3 day');
            $estimated_delivery_date = $date->format('Y-m-d');
            $merchantreviews_merchant_id = Configuration::get('PSOFT_MERCHANTREVIEWS_ID');
            $merchantreviews_order_id = (int) Tools::getValue('id_order');
            $merchantreviews_email = $this->context->customer->email;
            $merchantreviews_country = $this->context->country->iso_code;



            return '<script src="https://apis.google.com/js/platform.js?onload=renderOptIn"
  async defer>
</script>
    <script type="text/javascript">
        window.renderOptIn = function () {
window.gapi.load("surveyoptin", function () {
                window.gapi.surveyoptin.render({
                "merchant_id": "' . $merchantreviews_merchant_id . '",
                            "order_id": "' . $merchantreviews_order_id . '",
                            "email": "' . $merchantreviews_email . '",
                            "delivery_country": "' . $merchantreviews_country . '",
                            "estimated_delivery_date": "' . $estimated_delivery_date . '",
                            "opt_in_style": "CENTER_DIALOG"
                    });
                });
        }
    </script>
    <script type="text/javascript">
        window.___gcfg = {
            lang: "pl"
        };
    </script>
    ';
        }
    }

它是如何看待源代码的,html。

<script src="https://apis.google.com/js/platform.js?onload=renderOptIn"
  async defer>
</script>
    <script type="text/javascript">
        window.renderOptIn = function () {
window.gapi.load("surveyoptin", function () {
                window.gapi.surveyoptin.render({
                "merchant_id": "120321173",
                            "order_id": "32",
                            "email": "pub@prestashop.com",
                            "delivery_country": "PL",
                            "estimated_delivery_date": "2018-02-26",
                            "opt_in_style": "CENTER_DIALOG"
                    });
                });
        }
    </script>
    <script type="text/javascript">
        window.___gcfg = {
            lang: "pl"
        };

感谢您的帮助。

- 编辑 现在在控制台中我看到了:

Content Security Policy: Ignorowanie „'unsafe-inline'” w script-src: określono „strict-dynamic”
Content Security Policy: Ignorowanie „https:” w script-src: określono „strict-dynamic”
Content Security Policy: Ignorowanie „http:” w script-src: określono „strict-dynamic”

0 个答案:

没有答案
相关问题