I’m using the createOrder() API and want to add multiple items to my order. Currently I only can do it for one item per order.
Do I need to change something in this JSON file or how can I solve my problem?
In this following JSON is only space for one item…
In the createOrders API, you want to look at lineItems which takes an array of items.
Documentation Link
Could you give me an example how it would look like? I can‘t imagine how you would make an Array out of it?
The example is in the documentation and I’ve copy/pasted below. As you can see, lineItems is an array and you can keep adding new item objects here
line items
"lineItems": [
{
"quantity": 1,
"name": "my item",
"priceData": {
"price": 5
}
}
],
code from the API docs
import wixStoresBackend from 'wix-stores-backend';
export function createOrder() {
return wixStoresBackend.createOrder(minimumOrder);
}
const minimumOrder = {
"lineItems": [
{
"quantity": 1,
"name": "my item",
"priceData": {
"price": 5
}
}
],
"totals": {
"subtotal": 5,
"total": 5
},
"channelInfo": {
"type": "WEB"
},
"paymentStatus": "PAID",
"shippingInfo": {
"shipmentDetails": {
"address": {
"city": "New York",
"country": "US",
"addressLine": "235 W 23rd St",
"postalCode": "10011",
"subdivision": "NY"
}
}
},
"billingInfo": {
"address": {
"city": "New York",
"country": "US",
"addressLine": "235 W 23rd St",
"postalCode": "10011",
"subdivision": "NY"
}
}
}
Alright, I got it! Thanks a lot
Amazing!! GLad it’s working out, if you run into any new questions please start a new thread. Happy coding!