I’ve been awake for well over 24 hours at this point because I couldn’t figure out this problem… but I finally see what it is and why it’s not working and now I am so tired that I’m out of brain juice to finish this last piece out.
So, the goal is to take the lineItems out of getCurrentCart() to createOrder() and be happy. After getting the error below:
I thought, hmmm, but the prices are in there, no? Here is what the fields for lineItems for get CurrentCart():
And now see the difference with createOrder’s lineItems:
So what I’ve figured out is that although I was trying to take from my main page getCurrentCart() via:
export async function button10_click(event) {
const cart = await getCurrentCart()
let cartId = cart._id;
let cartItems = cart.lineItems; //----right here-----//
And then passing it to orders.jsw via:
export function createOrder(email, first, last, address, city, country, region, postal, telephone, cartItems //---right here---//, subtotal, total, cartId) {
let pretty = address + " " + city + " " + region + " " + postal;
const fullOrder = {
"buyerLanguage": null,
"cartId": cartId,
"currency": "EUR",
"weightUnit": "KG",
"billingInfo": {
"address": {
"formatted": pretty,
"city": city,
"country": country,
"addressLine": address,
"postalCode": postal,
"subdivision": region
},
"lastName": last,
"firstName": first,
"email": email,
"phone": telephone,
"company": null,
"paymentMethod": null,
"paymentGatewayTransactionId": null,
"paymentProviderTransactionId": null
},
"totals": {
"subtotal": subtotal,
"total": total,
"shipping": 0
},
"channelInfo": {
"type": "WEB"
},
"paymentStatus": "PAID",
"shippingInfo": {
"deliverByDate": null,
"deliveryOption": "Free Shipping",
"shippingRegion": "Domestic",
"estimatedDeliveryTime": "",
"shipmentDetails": {
"address": {
"formatted": pretty,
"city": city,
"country": country,
"addressLine": address,
"postalCode": postal,
"subdivision": region
},
"lastName": last,
"firstName": first,
"email": email,
"phone": telephone,
"company": "",
"shipmentPriceData": {
"price": 0,
"taxIncludedInPrice": false
}
}
},
"lineItems": cartItems //---------and right here is where it could be so much easier if it was a 1:1----------//
}
I finally realized why it won’t work and it’s because the data from one is completely missing the very important structured data to plop it into the other.
So, if any of y’all might have some brain juice (mine’s toast)… what is the best way to insert for each item in the array the following (because this is for creating a quote, all items are zero anyway)?:
109 "priceData": {
110 "price": 0,
111 "taxIncludedInPrice": true
112 }
End result should be where I can define something new like newCartItems and the goal is for that to be inserted into each item in the array (so, for example, it would be inserted into each of these, which are called from the current getCartItems():
I’m pretty sure .map is the way to go, but as I said, my brain is a saaaaad stale toast.