Answer the question
In order to leave comments, you need to log in
How to summarize orders by JSON data, JS?
{
"result":[
{
"order_id":НННННН,
"order_number":"НННННН",
"posting_number":"НННННН",
"status":"НННННН",
"cancel_reason_id":НННННН,
"created_at":"НННННН",
"in_process_at":"НННННН",
"products":[
{
"sku":ББББББ,
"name":"ББББББ",
"quantity":1,
"offer_id":"ББББББ",
"price":"1111.00"
}
],
"analytics_data":null,
"financial_data":null
},
{
"order_id":НННННН,
"order_number":"НННННН",
"posting_number":"НННННН",
"status":"НННННН",
"cancel_reason_id":НННННН,
"created_at":"НННННН",
"in_process_at":"НННННН",
"products":[
{
"sku":ББББББ,
"name":"ББББББ",
"quantity":1,
"offer_id":"ББББББ",
"price":"1612.00"
},
{
"sku":ВВВВВВ,
"name":"ВВВВВВ",
"quantity":1,
"offer_id":"ВВВВВВ",
"price":"1089.00"
}
],
"analytics_data":null,
"financial_data":null
},
Answer the question
In order to leave comments, you need to log in
const calculateFinalAmount = cart => {
return cart.reduce((cartTotal, record) => {
const recordTotal = record.products.reduce((recordTotal, product) => {
return recordTotal + parseFloat(product.price) * product.quantity;
}, 0);
return cartTotal + recordTotal;
}, 0);
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question