I have the following JS code that I use to create an object:
var TransactionData = {
orderId: '@Model.Order.SalesOrderNumber.SelfOrDefault().FullOrderNuber',
curreny: "USD",
total: '@Model.Order.TotalSalesPrice',
items: [
{
@foreach (var item in Model.Order.LineItems)
{
sku: item.ProductId,
quantity: item.Quantity,
price: item.AdjustedUnitPrice
}
}]
}
I need to loop through the LineItems in my Model to get the sku, quantity and price. There are 1 to x items that need to be created. Using the code above I get the error "; expected" after the comma in the sku:, quantity: and price: lines. Ultimately I am trying to get the following in the items:
{
"price" : "140",
"quantity" : "1",
"sku" : "156278"
},
{
"price" : "12.69",
"quantity" : "3",
"sku" : "908736"
}
I think I am almost there I just need to fix this error. Any suggestions? I am rusty on JS on RAZOR so please bear with me.
Thanks.