I'm having trouble figuring out how to iterate over an array and sum the values. Here is where I am so far. Is there another way to do this?
{{#each discount_applications}}{{sum this.value}}{{/each}}
Result: {"discount_amount": "36.113.99120"}
Context json:
{...
"discount_applications": [
{
"target_type": "line_item",
"type": "manual",
"value": "36.11",
"value_type": "fixed_amount",
"allocation_method": "each",
"target_selection": "explicit",
"title": "Capturing Fixed Discount",
"description": "Capturing Fixed Discount"
},
{
"target_type": "shipping_line",
"type": "script",
"value": "3.99",
"value_type": "fixed_amount",
"allocation_method": "across",
"target_selection": "explicit",
"title": "Free Standard Shipping",
"description": "Free Standard Shipping"
},
{
"target_type": "line_item",
"type": "discount_code",
"value": "120.0",
"value_type": "fixed_amount",
"allocation_method": "across",
"target_selection": "all",
"code": "CXGLM-3X-jrshifflett270"
}
],
...}