Skip to content

Commit

Permalink
fix(add-item): prevent changing original item object (param)
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Jun 30, 2020
1 parent c2d61e3 commit c78fa77
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/methods/add-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ export default ({ data, save }, emitter, [newItem, canSave = false]) => {
}

if (!fixedItem) {
const itemCopy = Object.assign({}, newItem)
if (!newItem._id || newItem._id === newItem.variation_id) {
newItem._id = randomObjectId()
itemCopy._id = randomObjectId()
}
data.items.push(newItem)
fixedItem = fixItemQuantity(newItem)
data.items.push(itemCopy)
fixedItem = fixItemQuantity(itemCopy)
}
fixSubtotal(data)

Expand Down

0 comments on commit c78fa77

Please sign in to comment.