Given this resource:
{
"data": [
[
{
"id": "6402565",
"recordType": "itemfulfillment",
"TrackingNumber": "593470228420",
"Ship Via": "FedEx Ground",
"ItemName": "WP36-HON-3P",
"Quantity": "1",
"Document Number": "IF120193",
"SellBrite Order Number": "13999",
"Carrier": "Standard"
},
{
"id": "6402565",
"recordType": "itemfulfillment",
"TrackingNumber": "593470228360",
"Ship Via": "FedEx Ground",
"ItemName": "WP36-HON-3P",
"Quantity": "1",
"Document Number": "IF120193",
"SellBrite Order Number": "13999",
"Carrier": "Standard"
}
]
]
}
And this template:
{
"shipment":
{{#each data}}
{{#if @index}} , {{/if}}
{
"sb_order_seq": {{this.0.[SellBriteOrderNumber]}},
"tracking_number": "{{this.0.TrackingNumber}}",
"carrier_name": "FedEx",
"tracking_url": "",
"warehouse_uuid": "b02fa8bc-9b01-43de-b9e7-f69ead1b9a98",
"shipping_method": "FedEx Ground",
"items": [
{{#each this}}
{{#if @index}} , {{/if}}
{
"sku": "{{ItemName}}",
"quantity": {{Quantity}}
}
{{/each}}
]
}
{{/each}}
}
I would like to output just one...
{
"sku": "{{ItemName}}",
"quantity": {{Quantity}}
}
...block but sum the {{Quantity}} for all iterations in the loop.
The host we are sending this to can't accept multpile tracking numbers for the same SKU so I want to add all quantities shipped to the first tracking number ({{this.0.TrackingNumber}})
Any thoughts?