创建此代码是为了在购买时传回值。项目部分上方的所有信息都已正确填充。 order.current.items引用包含id,special_price,qty的网站上的代码,但由于某种原因,它没有填充到函数中。
<script>
window.liQ = window.liQ || [];
window.liQ.push({
event: "conversion",
name: "product_purchase",
transactionId: "[[Checkout Success | Order | Increment ID]]",
amount: "[[Checkout Success | Order | Subtotal]]",
currency: "USD",
emailHash: "[[Checkout Success | User | MD5 Hash]]",
items: function() {
var pl = [];
var orderItems = order.current.items;
for (var i = 0; i < orderItems.length; ++i){
pl.push({
id: orderItems[i].id,
price: orderItems[i].special_price,
quantity: orderItems[i].qty
});
}
return pl;
}
}
);
</script>
答案 0 :(得分:0)
目前你只是说items
是一个功能。你实际上并没有执行它。一个解决方案:
items: (function() {
var pl = [];
var orderItems = order.current.items;
for (var i = 0; i < orderItems.length; ++i){
pl.push({
id: orderItems[i].id,
price: orderItems[i].special_price,
quantity: orderItems[i].qty
});
}
return pl;
}})();