Interface CommerceCartService
-
- All Known Subinterfaces:
B2BCommerceCartService
,SubscriptionCommerceCartService
- All Known Implementing Classes:
DefaultB2BCommerceCartService
,DefaultCommerceCartService
,DefaultSapCommerceCartService
,DefaultSubscriptionCommerceCartService
public interface CommerceCartService
Commerce service that exposes methods to deal with cart operations. This includes promotions and stock support.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description CommerceCartModification
addToCart(CommerceCartParameter parameter)
Adds to the (existing)CartModel
the (existing)ProductModel
in the givenUnitModel
and with the givenquantity
.CommerceCartModification
addToCart(CartModel cartModel, ProductModel productModel, long quantity, UnitModel unit, boolean forceNewEntry)
Deprecated.Since 5.2.CommerceCartModification
addToCart(CartModel cartModel, ProductModel productModel, PointOfServiceModel deliveryPointOfService, long quantity, UnitModel unit, boolean forceNewEntry)
Deprecated.Since 5.2.boolean
calculateCart(CommerceCartParameter parameter)
Calculates the givencartModel
and returnstrue
if each entry alone and after this theCartModel
was calculated.boolean
calculateCart(CartModel cartModel)
Deprecated.Since 5.2.void
configureCartEntry(CommerceCartParameter parameters)
Update configuration on a configurable product.CommerceTaxEstimateResult
estimateTaxes(CommerceCartParameter parameters)
Estimate taxes for the cartModel and using the deliveryZipCode as the delivery zip code.java.math.BigDecimal
estimateTaxes(CartModel cartModel, java.lang.String deliveryZipCode, java.lang.String deliveryCountryIso)
Deprecated.Since 5.2.CartModel
getCartForCodeAndUser(java.lang.String code, UserModel user)
Locate a cart for the specified guid and site and user.CartModel
getCartForGuidAndSite(java.lang.String guid, BaseSiteModel site)
Locate a cart for the specified guid and siteCartModel
getCartForGuidAndSiteAndUser(java.lang.String guid, BaseSiteModel site, UserModel user)
Locate a cart for the specified guid and site and user.java.util.List<CartModel>
getCartsForSiteAndUser(BaseSiteModel site, UserModel user)
Locate all carts for the specified site and user.void
mergeCarts(CartModel fromCart, CartModel toCart, java.util.List<CommerceCartModification> modifications)
Merge two carts and add modificationsvoid
recalculateCart(CommerceCartParameter parameter)
Recalculates the whole cart and all its entries.void
recalculateCart(CartModel cartModel)
Deprecated.Since 5.2.void
removeAllEntries(CommerceCartParameter parameter)
Removes all entries from the givenCartModel
.void
removeAllEntries(CartModel cartModel)
Deprecated.Since 5.2.CommerceCartModification
removeEntryGroup(RemoveEntryGroupParameter parameters)
Remove entry group and all cart entries of the group and it's descendants from the cart.void
removeStaleCarts(CommerceCartParameter parameters)
void
removeStaleCarts(CartModel currentCart, BaseSiteModel baseSite, UserModel user)
Deprecated.Since 5.2.CommerceCartRestoration
restoreCart(CommerceCartParameter parameters)
Restores the current customer's cart.CommerceCartRestoration
restoreCart(CartModel oldCart)
Deprecated.Since 5.2.long
split(CommerceCartParameter parameters)
Split existing cart entry.long
split(CartModel cartModel, long entryNumber)
Deprecated.Since 5.2.void
updateCartMetadata(CommerceCartMetadataParameter parameter)
Updates cart metadata, such as: name, description, expiration time.CommerceCartModification
updatePointOfServiceForCartEntry(CommerceCartParameter parameters)
Updates given cart entry model with point of service.CommerceCartModification
updatePointOfServiceForCartEntry(CartModel cartModel, long entryNumber, PointOfServiceModel pointOfServiceModel)
Deprecated.Since 5.2.CommerceCartModification
updateQuantityForCartEntry(CommerceCartParameter parameter)
Update quantity for the cart entry with givenentryNumber
with the givennewQuantity
.CommerceCartModification
updateQuantityForCartEntry(CartModel cartModel, long entryNumber, long newQuantity)
Deprecated.Since 5.2.CommerceCartModification
updateToShippingModeForCartEntry(CommerceCartParameter parameters)
Update the shipping mode for a given cart entryCommerceCartModification
updateToShippingModeForCartEntry(CartModel cartModel, long entryNumber)
Deprecated.Since 5.2.java.util.List<CommerceCartModification>
validateCart(CommerceCartParameter parameter)
Method for validating every entry in the cartjava.util.List<CommerceCartModification>
validateCart(CartModel cartModel)
Deprecated.Since 5.2.
-
-
-
Method Detail
-
addToCart
@Deprecated(since="5.2") CommerceCartModification addToCart(CartModel cartModel, ProductModel productModel, long quantity, UnitModel unit, boolean forceNewEntry) throws CommerceCartModificationException
Deprecated.- Parameters:
cartModel
- the user's cart in sessionproductModel
- theProductModel
to addquantity
- the quantity to addunit
- the UnitModel of the product @seeProductModel.getUnit()
forceNewEntry
- the flag for creating a newCartEntryModel
- Returns:
- the cart modification
- Throws:
CommerceCartModificationException
-
addToCart
CommerceCartModification addToCart(CommerceCartParameter parameter) throws CommerceCartModificationException
Adds to the (existing)CartModel
the (existing)ProductModel
in the givenUnitModel
and with the givenquantity
. If in the cart already an entry with the given product and given unit exists the givenquantity
is added to the the quantity of this cart entry unlessforceNewEntry
is set to true. After this the cart is calculated.- Parameters:
parameter
- - A parameter object containing all attributes needed for add to cartCommerceCartParameter.cart
- The user's cart in sessionCommerceCartParameter.pointOfService
- The store object for pick up in store items (only needs to be passed in if you are adding an item to pick upCommerceCartParameter.product
- TheProductModel
to addCommerceCartParameter.quantity
- The quantity to addCommerceCartParameter.unit
- The UnitModel of the product @seeProductModel.getUnit()
CommerceCartParameter.createNewEntry
- The flag for creating a newCartEntryModel
- Returns:
- the cart modification data that includes a statusCode and the actual quantity added to the cart
- Throws:
CommerceCartModificationException
- if theproduct
is a base product OR the quantity is less than 1 or no usable unit was found (only when givenunit
is alsonull
) or any other reason the cart could not be modified.
-
addToCart
@Deprecated(since="5.2") CommerceCartModification addToCart(CartModel cartModel, ProductModel productModel, PointOfServiceModel deliveryPointOfService, long quantity, UnitModel unit, boolean forceNewEntry) throws CommerceCartModificationException
Deprecated.- Parameters:
cartModel
- the user's cart in sessionproductModel
- theProductModel
to adddeliveryPointOfService
- the delivery storequantity
- the quantity to addunit
- the UnitModel of the product @seeProductModel.getUnit()
forceNewEntry
- the flag for creating a newCartEntryModel
- Returns:
- the cart modification
- Throws:
CommerceCartModificationException
-
validateCart
java.util.List<CommerceCartModification> validateCart(CommerceCartParameter parameter) throws CommerceCartModificationException
Method for validating every entry in the cart- Parameters:
parameter
-- Returns:
- a list of cart modifications data that includes a statusCode and the actual quantity that the entry was updated to
- Throws:
CommerceCartModificationException
- if the cart could not be modified.
-
validateCart
@Deprecated(since="5.2") java.util.List<CommerceCartModification> validateCart(CartModel cartModel) throws CommerceCartModificationException
Deprecated.- Parameters:
cartModel
- the user's cart in session- Returns:
- a
List
of cart modifications - Throws:
CommerceCartModificationException
-
calculateCart
boolean calculateCart(CommerceCartParameter parameter)
Calculates the givencartModel
and returnstrue
if each entry alone and after this theCartModel
was calculated. Thereby any invalid entry will be automatically removed. The net/gross prices depends on the current session user, seePriceFactory.isNetUser(de.hybris.platform.jalo.user.User)
for more information.- Parameters:
parameter
- the parameter object holding the existingCartModel
that will be calculated- Returns:
false
if thecartModel
was already calculated.
-
calculateCart
@Deprecated(since="5.2") boolean calculateCart(CartModel cartModel)
Deprecated.Since 5.2. UsecalculateCart(de.hybris.platform.commerceservices.service.data.CommerceCartParameter)
instead.- Parameters:
cartModel
- the user's cart in session- Returns:
false
if thecartModel
was already calculated
-
recalculateCart
@Deprecated(since="5.2") void recalculateCart(CartModel cartModel) throws CalculationException
Deprecated.Since 5.2. UserecalculateCart(de.hybris.platform.commerceservices.service.data.CommerceCartParameter)
instead- Parameters:
cartModel
- the user's cart in session- Throws:
CalculationException
-
recalculateCart
void recalculateCart(CommerceCartParameter parameter) throws CalculationException
Recalculates the whole cart and all its entries. This includes finding prices, taxes, discounts, payment and delivery costs by calling the currently installed price factory.- Parameters:
parameter
- A parameter object holding the cart modelCartModel
(must exist) that will be recalculatedCartModel
- Throws:
CalculationException
- the calculation exception
-
removeAllEntries
@Deprecated(since="5.2") void removeAllEntries(CartModel cartModel)
Deprecated.Since 5.2. UseremoveAllEntries(de.hybris.platform.commerceservices.service.data.CommerceCartParameter)
instead- Parameters:
cartModel
- the user's cart in session
-
removeAllEntries
void removeAllEntries(CommerceCartParameter parameter)
Removes all entries from the givenCartModel
.- Parameters:
parameter
- A parameter object holding theCartModel
that will be emptied
-
updateQuantityForCartEntry
@Deprecated(since="5.2") CommerceCartModification updateQuantityForCartEntry(CartModel cartModel, long entryNumber, long newQuantity) throws CommerceCartModificationException
Deprecated.- Parameters:
cartModel
- the user's cart in sessionentryNumber
- the cart entry numbernewQuantity
- the new quantity- Returns:
- the cart modification
- Throws:
CommerceCartModificationException
-
updateQuantityForCartEntry
CommerceCartModification updateQuantityForCartEntry(CommerceCartParameter parameter) throws CommerceCartModificationException
Update quantity for the cart entry with givenentryNumber
with the givennewQuantity
. Then cart is calculated.- Parameters:
parameter
- - A parameter object containing all attributes needed for add to cartCommerceCartParameter.cart
- The user's cart in sessionCommerceCartParameter.pointOfService
- The store object for pick up in store items (only needs to be passed in if you are adding an item to pick upCommerceCartParameter.product
- TheProductModel
to addCommerceCartParameter.quantity
- The quantity to addCommerceCartParameter.unit
- The UnitModel of the product @seeProductModel.getUnit()
CommerceCartParameter.createNewEntry
- The flag for creating a newCartEntryModel
- Returns:
- the cart modification data that includes a statusCode and the actual quantity that the entry was updated to
- Throws:
CommerceCartModificationException
- if theproduct
is a base product OR the quantity is less than 1 or no usable unit was found (only when givenunit
is alsonull
) or any other reason the cart could not be modified.
-
updatePointOfServiceForCartEntry
@Deprecated(since="5.2") CommerceCartModification updatePointOfServiceForCartEntry(CartModel cartModel, long entryNumber, PointOfServiceModel pointOfServiceModel) throws CommerceCartModificationException
Deprecated.- Parameters:
cartModel
- the user's cart in sessionentryNumber
- the cart entry numberpointOfServiceModel
- the point of service- Returns:
- the cart modification
- Throws:
CommerceCartModificationException
-
updatePointOfServiceForCartEntry
CommerceCartModification updatePointOfServiceForCartEntry(CommerceCartParameter parameters) throws CommerceCartModificationException
Updates given cart entry model with point of service.- Parameters:
parameters
- - A bean holding any number of additional parameters a client may want to pass to the method for extension purposes, the attributes can be added to the bean via beans.xml in your extensions- Returns:
CommerceCartModification
object- Throws:
CommerceCartModificationException
-
updateToShippingModeForCartEntry
@Deprecated(since="5.2") CommerceCartModification updateToShippingModeForCartEntry(CartModel cartModel, long entryNumber) throws CommerceCartModificationException
Deprecated.- Parameters:
cartModel
- the user's cart in sessionentryNumber
- the cart entry number- Returns:
- the cart modification
- Throws:
CommerceCartModificationException
-
updateToShippingModeForCartEntry
CommerceCartModification updateToShippingModeForCartEntry(CommerceCartParameter parameters) throws CommerceCartModificationException
Update the shipping mode for a given cart entry- Parameters:
parameters
- - A bean holding any number of additional parameters a client may want to pass to the method for extension purposes, the attributes can be added to the bean via beans.xml in your extensions- Returns:
CommerceCartModification
object- Throws:
CommerceCartModificationException
-
split
@Deprecated(since="5.2") long split(CartModel cartModel, long entryNumber) throws CommerceCartModificationException
Deprecated.- Parameters:
cartModel
- the user's cart in sessionentryNumber
- the cart entry number- Returns:
- the number of the newly created entry
- Throws:
CommerceCartModificationException
-
split
long split(CommerceCartParameter parameters) throws CommerceCartModificationException
Split existing cart entry. The entry must have a quantity greater than 1. One of the quantity from the original entry is moved to the new cart entry.- Parameters:
parameters
- - A bean holding any number of additional parameters a client may want to pass to the method for extension purposes, the attributes can be added to the bean via beans.xml in your extensions- Returns:
- The number of the newly created entry.
- Throws:
CommerceCartModificationException
-
restoreCart
@Deprecated(since="5.2") CommerceCartRestoration restoreCart(CartModel oldCart) throws CommerceCartRestorationException
Deprecated.- Parameters:
oldCart
- the old cart to restore- Returns:
- details of any items that could not be restored in part or in full
- Throws:
CommerceCartRestorationException
-
restoreCart
CommerceCartRestoration restoreCart(CommerceCartParameter parameters) throws CommerceCartRestorationException
Restores the current customer's cart.- Parameters:
parameters
- - A bean holding any number of additional parameters a client may want to pass to the method for extension purposes, the attributes can be added to the bean via beans.xml in your extensions- Returns:
- details of any items that could not be restored in part or in full.
- Throws:
CommerceCartRestorationException
- if any problems occur in restoring the cart
-
getCartForGuidAndSiteAndUser
CartModel getCartForGuidAndSiteAndUser(java.lang.String guid, BaseSiteModel site, UserModel user)
Locate a cart for the specified guid and site and user. If guid is null, the most recently modified user cart is returned.- Parameters:
guid
- a unique identifiersite
- the current BaseSite - may not be nulluser
- the current user - may not be null- Returns:
- the specified cart
-
getCartForGuidAndSite
CartModel getCartForGuidAndSite(java.lang.String guid, BaseSiteModel site)
Locate a cart for the specified guid and site- Parameters:
guid
-site
-- Returns:
- the specified cart
-
getCartForCodeAndUser
CartModel getCartForCodeAndUser(java.lang.String code, UserModel user)
Locate a cart for the specified guid and site and user.- Parameters:
code
-user
-- Returns:
- the specified cart
-
getCartsForSiteAndUser
java.util.List<CartModel> getCartsForSiteAndUser(BaseSiteModel site, UserModel user)
Locate all carts for the specified site and user.- Parameters:
site
-user
-- Returns:
- list of specified carts
-
estimateTaxes
@Deprecated(since="5.2") java.math.BigDecimal estimateTaxes(CartModel cartModel, java.lang.String deliveryZipCode, java.lang.String deliveryCountryIso)
Deprecated.Since 5.2. UseestimateTaxes(de.hybris.platform.commerceservices.service.data.CommerceCartParameter)
instead.Estimate taxes for the cartModel and using the deliveryZipCode as the delivery zip code.- Parameters:
cartModel
- cart to estimate taxes fordeliveryZipCode
- zip code to use as the delivery addressdeliveryCountryIso
- country isocode used as the delivery address- Returns:
- total of the estimated taxes
-
estimateTaxes
CommerceTaxEstimateResult estimateTaxes(CommerceCartParameter parameters)
Estimate taxes for the cartModel and using the deliveryZipCode as the delivery zip code.- Parameters:
parameters
- A parameter object holding the following properties - cartModel cart to estimate taxes for - deliveryZipCode zip code to use as the delivery address - deliveryCountryIso country iso code used as the delivery address- Returns:
- A result object with the total of the estimated taxes
-
removeStaleCarts
@Deprecated(since="5.2") void removeStaleCarts(CartModel currentCart, BaseSiteModel baseSite, UserModel user)
Deprecated.Since 5.2. UseremoveStaleCarts(de.hybris.platform.commerceservices.service.data.CommerceCartParameter)
instead.Remove the old carts for the user.- Parameters:
currentCart
- the current user's cartbaseSite
- the current base siteuser
- the current user
-
removeStaleCarts
void removeStaleCarts(CommerceCartParameter parameters)
- Parameters:
parameters
- a parameter object holding the following values - cart Users Cart - baseSite Current base site - user Current user
-
mergeCarts
void mergeCarts(CartModel fromCart, CartModel toCart, java.util.List<CommerceCartModification> modifications) throws CommerceCartMergingException
Merge two carts and add modifications- Parameters:
fromCart
- the cart to mergetoCart
- the target cartmodifications
- the list of modifications- Throws:
CommerceCartMergingException
-
configureCartEntry
void configureCartEntry(CommerceCartParameter parameters) throws CommerceCartModificationException
Update configuration on a configurable product.- Parameters:
parameters
-cart
entryNumber
product
productConfigurator
productConfiguration
- Throws:
CommerceCartModificationException
- if product is not configurable orentry
is invalidjava.lang.IllegalArgumentException
- ifconfiguration
contains
-
updateCartMetadata
void updateCartMetadata(CommerceCartMetadataParameter parameter)
Updates cart metadata, such as: name, description, expiration time.- Parameters:
parameter
- a bean holding any number of additional attributes a client may want to pass to the method for extension purposes, the attributes can be added to the bean via beans.xml in your extensions- Throws:
java.lang.IllegalArgumentException
- if any attributes fail validationIllegalQuoteStateException
- if the cart is associated with a quote for which the operation cannot be performed
-
removeEntryGroup
@Nonnull CommerceCartModification removeEntryGroup(@Nonnull RemoveEntryGroupParameter parameters) throws CommerceCartModificationException
Remove entry group and all cart entries of the group and it's descendants from the cart.- Parameters:
parameters
- a parameter object containing all attributes needed for remove group from the cartcart
user's cartentryGroupNumber
number of entry group to be removedenableHooks
should the method hooks be executed
- Returns:
CommerceCartModification
object- Throws:
CommerceCartModificationException
- if related cart entry wasn't removed.
-
-