I have an array of collections containing product sales information e.g. product name, cost, tax, product id etc. The array has multiple products in it which will be used to create an invoice in Xero.
I need to add another item to this collection which has the shipping details for the order.
example code:
Array of product items:
[
{
"__IMTKEY__": 1,
"array": [
{
"ID": 102,
"TaxType": null,
"Quantity": 4,
"itemCode": null,
"UnitAmount": "10.25",
"lineItemID": null,
"orderTotal": "41.00",
"Description": "2472/2476-Half Caff",
"DiscountRate": 0,
"lineItemName": null,
"websiteOrderNumber": 4279
}
]
}
]
And the shipping information:
[
{
"ID": 14,
"TaxType": null,
"Quantity": 1,
"itemCode": null,
"UnitAmount": "5.00",
"lineItemID": null,
"orderTotal": "5.00",
"Description": "First Class Royal Mail",
"DiscountRate": 0,
"lineItemName": null,
"websiteOrderNumber": null
}
]
As the shipping info doesn’t have a collection name (which I’d thought I could have used add() function) how do I add the shipping info collection into the array?