Created
September 25, 2018 07:52
-
-
Save anantl05/d2180c0aeae10456ace881336f824073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Pass the orderItems array that you get | |
getDataArray(arr) { | |
const uniqByArr = uniqBy(arr, 'item_id'); | |
let finalArr = []; | |
uniqByArr.map((item,idx) => { | |
const item_id = item.item_id; | |
let qty = 0; | |
arr.map((actualItem) => { | |
if (item_id === actualItem.item_id) { | |
qty += 1; | |
} | |
}) | |
const obj = {...item}; | |
obj.quantity = qty; | |
finalArr.push(obj); | |
}) | |
return finalArr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment