I want to create an array of objects on the checkout page like this:
items = [
{
productId: "P001",
size: "L",
variantId: "P001_SIZEL_RED",
url: "http://example.com/products/P001",
imageUrl: "http://images.example.com/products/P001/red/image1xl.jpg",
color: "Red",
unitPrice: 5100,
quantity: 1,
gender: "W"
}
...// Create an object for each of the items that were purchased in the order
]
I can get the individual values by looping through checkout.line_items but I can’t figure out how to store them as objects and push them into an array. Can you please help me?
Just note that in using this method, you must refresh the page to update your javascript. To use ajax, and update without refreshing, I’d suggest using cartjs.