I have the following snippet of JavaScript I am wrestling with:
window.bvCallback = function (BV) { BV.pixel.trackTransaction({
"currency" : "value",
"orderId" : "@Model.Order.OrderNumber",
"total" : "@Model.Order.Total",
"items" : [
{ -->need a foreach here to loop through the collection to make this key/value pairing for each item
"price" : "value",
"quantity" : "value",
"sku" : "value"
}
]
});
};
The problem I have is with the "items" : []
line. I have a collection I need to iterate to create the price quantity and SKU values. This snippet will work to iterate the items:
foreach (var item in Model.Order.LineItems) {item.AdjustedUnitPrice item.sku ...};
So my final outcome needs to be as follows:
..."items" : [
{
"price" : "140",
"quantity" : "1",
"sku" : "156278"
},
{
"price" : "12.69",
"quantity" : "3",
"sku" : "908736"
}]...
So I can get the values I need in the LineItems
collection, I just can't seem to put the foreach into the key/value pairing above to get when I need.