(productId)
| 23 | } |
| 24 | |
| 25 | export function addToCart(productId) { |
| 26 | let matchingItem; |
| 27 | |
| 28 | cart.forEach((cartItem) => { |
| 29 | if (productId === cartItem.productId) { |
| 30 | matchingItem = cartItem; |
| 31 | } |
| 32 | }); |
| 33 | |
| 34 | if (matchingItem) { |
| 35 | matchingItem.quantity += 1; |
| 36 | } else { |
| 37 | cart.push({ |
| 38 | productId: productId, |
| 39 | quantity: 1, |
| 40 | deliveryOptionId: '1' |
| 41 | }); |
| 42 | } |
| 43 | |
| 44 | saveToStorage(); |
| 45 | } |
| 46 | |
| 47 | export function removeFromCart(productId) { |
| 48 | const newCart = []; |
no test coverage detected