Google电子商务Scripts for Hotcakes电子商务模块

时间:2016-04-20 03:12:26

标签: e-commerce dotnetnuke

我正在为我的网站使用Hotcakes电子商务工具。我的网站正在使用DNN平台。

由于我有2个不同的网站和产品需要跟踪谷歌电子商务,因此我需要2套谷歌电子商务代码。

一个是ga('ecommerce:send');,这很好,另一个是ga('Hatch.ecommerce:send');

但Hotcakes不允许我修改Google电子商务代码。因此,我必须将其关闭并自行编辑到视图模型中

我已经实现了代码,但它会导致页面上出现查看错误。

任何人都可以帮我解决这个问题吗?

它给出了此错误消息“发生了错误。错误:结帐当前不可用。“

这是“receipt.cshtml”的代码。我添加了谷歌电子商务代码的底部附近:

@model Hotcakes.Modules.Core.Models.OrderViewModel
<div class="hc-receipt">
<h2>Thank you for purchasing</h2>
We know you will love creating beautiful embroidery designs with our Hatch products.<br /><br />
<a href="https://dyul59n6ntr4m.cloudfront.net/Hatch_Setup.exe">Click here to download Hatch Embroidery</a><br /><br />
<strong>You are not required to download Hatch If you purchased:</strong>
<ul>
<li>Additional Hatch add-ons</li>
<li>An UPGRADE to Embroidery Creator or Embroidery Digitizer</li>
<li>Hatch Fonts Packs</li>
</ul>
Simply RESTART the software for your new purchase to be available.<br />
Have fun and please share your creations with us on our <a href="https://www.facebook.com/wilcom" target="new">Facebook page</a><br />
@Html.Partial("_SetFirstPassword")
@Html.Partial("_ViewOrder", Model)
@for (int i = 0; i < Model.Items.Count(); i++)
{
var item = Model.Items.ElementAt(i);
@item.ProductName
<span>@item.ProductSku</span><br />
**<script type="text/javascript">
ga('Hatch.ecommerce:addTransaction', {
'id': '149428',
'affiliation': 'Hatch Embroidery Online Shop',
'revenue': '0',
'shipping': '0',
'tax': '@model.LocalOrder.TotalTax',
'city': '@model.LocalOrder.BillingAddress.City',
'state': '@model.LocalOrder.BillingAddress.RegionDisplayName',
'country': '@model.LocalOrder.BillingAddress.CountryDisplayName'
});
ga('Hatch.ecommerce:addItem', {
'id': '@item.Id',
'name': '@item.ProductName',
'sku': '@item.ProductSku',
'category': 'Hatch Product',
'price': '@item.AdjustedPricePerItem',
'quantity': '@item.Quantity'
});
ga('Hatch.ecommerce:send');
</script>** 
}
</div>

如果客户购买多种产品,我认为必须在循环内部...... 如果你能提供一些暗示或帮助,那就太好了...... 谢谢 千斤顶

1 个答案:

答案 0 :(得分:1)

在查看您的代码时,&#34;模型&#34;中出现了一些拼写错误。与&#34; model&#34;,脚本标记中的其他空格和字符,以及产品名称未按照Razor期望使用它的方式正确使用。我不确定这是否能解决您遇到的所有问题,但到目前为止它们似乎都是Razor语法和拼写错误问题。

@model Hotcakes.Modules.Core.Models.OrderViewModel
<div class="hc-receipt">
    <h2>Thank you for purchasing</h2>
    We know you will love creating beautiful embroidery designs with our Hatch products.<br /><br />
    <a href="https://dyul59n6ntr4m.cloudfront.net/Hatch_Setup.exe">Click here to download Hatch Embroidery</a><br /><br />
    <strong>You are not required to download Hatch If you purchased:</strong>
    <ul>
        <li>Additional Hatch add-ons</li>
        <li>An UPGRADE to Embroidery Creator or Embroidery Digitizer</li>
        <li>Hatch Fonts Packs</li>
    </ul>
    Simply RESTART the software for your new purchase to be available.<br />
    Have fun and please share your creations with us on our <a href="https://www.facebook.com/wilcom" target="new">Facebook page</a><br />
    @Html.Partial("_SetFirstPassword")
    @Html.Partial("_ViewOrder", Model)
    @for (int i = 0; i < Model.Items.Count(); i++)
    {
        var item = @Model.Items.ElementAt(i);
        <text>@item.ProductName</text>
        <span>@item.ProductSku</span><br />
        <script type="text/javascript">
            ga('Hatch.ecommerce:addTransaction', {
                'id': '149428',
                'affiliation': 'Hatch Embroidery Online Shop',
                'revenue': '0',
                'shipping': '0',
                'tax': '@Model.LocalOrder.TotalTax',
                'city': '@Model.LocalOrder.BillingAddress.City',
                'state': '@Model.LocalOrder.BillingAddress.RegionDisplayName',
                'country': '@Model.LocalOrder.BillingAddress.CountryDisplayName'
            });
            ga('Hatch.ecommerce:addItem', {
                'id': '@item.Id',
                'name': '@item.ProductName',
                'sku': '@item.ProductSku',
                'category': 'Hatch Product',
                'price': '@item.AdjustedPricePerItem',
                'quantity': '@item.Quantity'
            });
            ga('Hatch.ecommerce:send');
        </script>
    }
</div>