Package com.jahnreil_stratpoint.service
Interface ICartService
- All Known Implementing Classes:
CartServiceImpl
public interface ICartService
Interface for managing the shopping cart operations.
-
Method Summary
Modifier and TypeMethodDescriptionaddCartItemToCart
(CartItem cartItem, Cart cart) Adds a cart item to the cart.Adds a product to the cart.void
checkout()
Performs checkout for the cart.decreaseCartItemFromItems
(Cart cart, Product product) Decreases the quantity of a product in the cart.Finds an item in the cart based on the product.removeCartItemFromCart
(CartItem cartItem, Cart cart) Removes a cart item from the cart.
-
Method Details
-
addToCart
Adds a product to the cart. If the product is already in the cart, increases its quantity.- Parameters:
product
- the product to addcart
- the cart to which the product is added- Returns:
- the updated cart
-
findItem
Finds an item in the cart based on the product.- Parameters:
cart
- the cart to searchproduct
- the product to find- Returns:
- an optional containing the found cart item, or empty if not found
-
addCartItemToCart
Adds a cart item to the cart.- Parameters:
cartItem
- the cart item to addcart
- the cart to which the item is added- Returns:
- the updated cart
-
removeCartItemFromCart
Removes a cart item from the cart.- Parameters:
cartItem
- the cart item to removecart
- the cart from which the item is removed- Returns:
- the updated cart
-
decreaseCartItemFromItems
Decreases the quantity of a product in the cart. If the quantity reaches 0, removes the item from the cart.- Parameters:
cart
- the cartproduct
- the product to decrease the quantity of- Returns:
- the updated cart
-
checkout
void checkout()Performs checkout for the cart.
-