public interface CartService extends AbstractOrderService<CartModel,CartEntryModel>
OrderModel, CartModel is a subtype of AbstractOrderModel, so
the service fulfills the contract of AbstractOrderService for the CartModel and
CartEntryModel types. Additionally it provides methods for handling the session cart.| Modifier and Type | Method and Description |
|---|---|
void |
addToCart(CartModel cart,
ProductModel product,
long quantity,
UnitModel unit)
Deprecated.
since 6.2.0 - Use
AbstractOrderService.addNewEntry(AbstractOrderModel, ProductModel, long, UnitModel) from
the cart service instead. Please mind the fact that
AbstractOrderService.addNewEntry(AbstractOrderModel, ProductModel, long, UnitModel) method
does not calculate or save the cart. |
void |
appendToCart(CartModel sourceCart,
CartModel targetCart)
Clones all entries of source cart to the target cart.
|
boolean |
calculateCart(CartModel cartModel)
Deprecated.
since 6.2.0 - Use
CalculationService.calculate(AbstractOrderModel) to calculate carts. |
void |
changeCurrentCartUser(UserModel user)
Changes the user of the session cart to the given user.
|
void |
changeSessionCartCurrency(CurrencyModel currency)
Changes the currency of the session cart to the given currency.
|
CartModel |
createCartFromQuote(QuoteModel quote)
Creates a new cart based on the given
QuoteModel. |
CartModel |
getSessionCart()
Returns the cart attached to the current session.
|
boolean |
hasCart()
Deprecated.
since 6.2.0 - use
hasSessionCart() |
boolean |
hasSessionCart()
Returns
true if the current session already holds a cart, false otherwise. |
void |
removeSessionCart()
If existing the current session cart is being detached from this session and removed.
|
void |
setSessionCart(CartModel cart)
Attach the cart to a session.
|
void |
updateQuantities(CartModel cart,
java.util.List<java.lang.Long> quantities)
Deprecated.
since 6.2.0 - Update cart entries quantities directly via
AbstractOrderEntryModel.setQuantity(Long) or use
updateQuantities(CartModel, Map) |
void |
updateQuantities(CartModel cart,
java.util.Map<java.lang.Integer,java.lang.Long> quantities)
Updates multiple cart entry quantities at once.
|
addAllGlobalDiscountValues, addAllTotalTaxValues, addGlobalDiscountValue, addNewEntry, addNewEntry, addNewEntry, addTotalTaxValue, clone, getEntriesForNumber, getEntriesForProduct, getEntryForNumber, getGlobalDiscountValue, removeGlobalDiscountValue, removeTotalTaxValue, saveOrder@Deprecated void addToCart(CartModel cart, ProductModel product, long quantity, UnitModel unit) throws InvalidCartException
AbstractOrderService.addNewEntry(AbstractOrderModel, ProductModel, long, UnitModel) from
the cart service instead. Please mind the fact that
AbstractOrderService.addNewEntry(AbstractOrderModel, ProductModel, long, UnitModel) method
does not calculate or save the cart.CartModel the (existing) ProductModel in the given UnitModel and
with the given quantity. If in the cart already an entry with the given product and given unit exists
the given quantity is added to the the quantity of this cart entry. After this the cart is
calculated.cart - the cart, must existproduct - the product which is added to the cartquantity - the quantity of the productunit - if null ProductService.getOrderableUnit(ProductModel) is used to determine the unitInvalidCartException - if the product is a base product OR the quantity is less 1 or no usable unit was found
(only when given unit is also null)void setSessionCart(CartModel cart)
CartModel getSessionCart()
CartFactory. As default a DefaultCartFactory is
being used.void removeSessionCart()
getSessionCart(),
setSessionCart(CartModel)boolean hasSessionCart()
true if the current session already holds a cart, false otherwise. Please use
this instead of getSessionCart() if you like to avoid unnecessary auto-creation of the session cart.getSessionCart()@Deprecated boolean hasCart()
hasSessionCart()@Deprecated boolean calculateCart(CartModel cartModel)
CalculationService.calculate(AbstractOrderModel) to calculate carts.cartModel and returns true if each entry and after this the
CartModel was calculated. Thereby any invalid entry will be automatically removed.cartModel - the CartModelfalse if the cartModel was already calculated.@Deprecated void updateQuantities(CartModel cart, java.util.List<java.lang.Long> quantities)
AbstractOrderEntryModel.setQuantity(Long) or use
updateQuantities(CartModel, Map)quantities. If the quantity value is 0 the
cart entry is removed.cart - the cart where the quantities are updatedquantities - the new quantity list for each cart entryvoid updateQuantities(CartModel cart, java.util.Map<java.lang.Integer,java.lang.Long> quantities)
cart - the cart to update cart entry quantities atquantities - the entry specific quantities as map of { entry number -> quantity }void appendToCart(CartModel sourceCart, CartModel targetCart)
CalculationService. The target cart is also not persisted after this method call.sourceCart - the cart providing the entries to copytargetCart - the target cart to create new entries forjava.lang.IllegalArgumentException - if targetCart is null.void changeCurrentCartUser(UserModel user)
user - new session cart userjava.lang.IllegalArgumentException - when user is nullvoid changeSessionCartCurrency(CurrencyModel currency)
currency - new session cart currencyCartModel createCartFromQuote(QuoteModel quote)
QuoteModel. Please note that it is the caller's responsibility to
persist the new cart returned by this method. The quote passed into this method will not be affected by its logic.quote - the quote modeljava.lang.IllegalArgumentException - when quote is nullCopyright © 2018 SAP SE. All Rights Reserved.