Hi Juraj, many thanks for that answer, it has resolved that issue, however, I an struggling to understand the logic of where/when you place the {%} to enclose the items of the foreach, can you advise please.
The reason to ask is, as part of this Javascript, I also need to add a line to pull in all the items of the cart, plus image, SKUID, url path, price etc.
The current settings I have is:
{% additems = foreach(cartItem in ECommerceContext.CurrentShoppingCart.CartProducts) { "ProductName:" + cartItem.SKU.SKUName + "," + "ProductID: " + cartItem.SKU.SKUID + "," + "SKU:" + cartItem.SKU.SKUName + "," + "Quantity: " + cartItem.SKUUnits + "," + "ItemPrice: " + cartItem.SKU.SKUPrice + "," + "RowTotal:" + cartItem.SKU.ItemTotal + "," + "ImageURL:" + cartItem.SKU.SKUIMagePath + "," + "ProductURL:" + cartItem.SKU.SKUAliasPath + "," } return; #%}
As you can see we also need to include text identifiers, so have been trying with just a few items until I can figure out the structure required:
{% additems = foreach(cartItem in ECommerceContext.CurrentShoppingCart.CartProducts) { %} "ProductName:""{% cartItem.SKU.SKUName %}, "ProductID: "{% cartItem.SKU.SKUID %}", {%} %} }return; #%}
But this is throwing errors plus the first item is repeated:
"items":[" "ProductName:""Siena Lady GTX Shoe: BRAUN - 5H, "ProductID: "7337",
"ProductName:""Siena Lady GTX Shoe: BRAUN - 5H, "ProductID: "7337", "ProductName:""Rab Mens Microlight Vest Black/Shark: Black/Shark - S, "ProductID: "23045", "],
}]);
I have tried searching for examples of strings like this but cannot find any?
Thanks for you advise on this.
Les