Commit 39ca21a0 authored by Shaphen Pangburn's avatar Shaphen Pangburn

[AFP-48 Shaphen Pangburn]: Increase quantity of existing produc tin cart if already existing

parent 56cd049f
......@@ -35,6 +35,14 @@ export default class ProductItem extends Component {
userId: this.props.user.currentUser.email,
cartItems: JSON.parse(JSON.stringify(this.props.cart)) // JSON.parse/stringify will deep-dup the object
})
for (let i = 0; i < newCart.cartItems.length; i++) {
let item = newCart.cartItems[i];
if(item.productRef.sku === product.sku) {
item.quantity += parseInt(this.state.orderItemQuantity)
this.props.addToCart(newCart, this.props.user.currentUser.email);
return;
}
}
const newCartItem = {
productRef: {
id: product.sku,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment