Esempio n. 1
0
  public void addCartItem(CartItem cartItem) {
    String productId = cartItem.getProduct().getProductId();

    if (cartItems.containsKey(productId)) {
      CartItem existingCartItem = cartItems.get(productId);
      existingCartItem.setQuantity(existingCartItem.getQuantity() + cartItem.getQuantity());
      cartItems.put(productId, existingCartItem);
    } else {
      cartItems.put(productId, cartItem);
    }

    updateGrandTotal();
  }
Esempio n. 2
0
 public void removeCartItem(CartItem cartItem) {
   String productId = cartItem.getProduct().getProductId();
   cartItems.remove(productId);
   updateGrandTotal();
 }