Class DefaultCommerceCartService
- java.lang.Object
-
- de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService
-
- All Implemented Interfaces:
CommerceCartService
- Direct Known Subclasses:
DefaultB2BCommerceCartService
,DefaultSapCommerceCartService
,DefaultSubscriptionCommerceCartService
public class DefaultCommerceCartService extends java.lang.Object implements CommerceCartService
Default implementation ofCommerceCartService
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
ESTIMATED_TAXES
-
Constructor Summary
Constructors Constructor Description DefaultCommerceCartService()
-
Method Summary
-
-
-
Field Detail
-
ESTIMATED_TAXES
protected static final java.lang.String ESTIMATED_TAXES
- See Also:
- Constant Field Values
-
-
Method Detail
-
addToCart
@Deprecated(since="5.2") public CommerceCartModification addToCart(CartModel cartModel, ProductModel productModel, long quantityToAdd, UnitModel unit, boolean forceNewEntry) throws CommerceCartModificationException
Deprecated.Since 5.2.- Specified by:
addToCart
in interfaceCommerceCartService
- Parameters:
cartModel
- the user's cart in sessionproductModel
- theProductModel
to addquantityToAdd
- 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
@Deprecated(since="5.2") public CommerceCartModification addToCart(CartModel cartModel, ProductModel productModel, PointOfServiceModel deliveryPointOfService, long quantity, UnitModel unit, boolean forceNewEntry) throws CommerceCartModificationException
Deprecated.Since 5.2.- Specified by:
addToCart
in interfaceCommerceCartService
- 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
-
addToCart
public CommerceCartModification addToCart(CommerceCartParameter parameter) throws CommerceCartModificationException
Description copied from interface:CommerceCartService
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.- Specified by:
addToCart
in interfaceCommerceCartService
- 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.
-
validateCart
public java.util.List<CommerceCartModification> validateCart(CommerceCartParameter parameter) throws CommerceCartModificationException
Description copied from interface:CommerceCartService
Method for validating every entry in the cart- Specified by:
validateCart
in interfaceCommerceCartService
- 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") public java.util.List<CommerceCartModification> validateCart(CartModel cartModel) throws CommerceCartModificationException
Deprecated.Since 5.2.- Specified by:
validateCart
in interfaceCommerceCartService
- Parameters:
cartModel
- the user's cart in session- Returns:
- a
List
of cart modifications - Throws:
CommerceCartModificationException
-
calculateCart
@Deprecated(since="5.2") public boolean calculateCart(CartModel cartModel)
Deprecated.Since 5.2.- Specified by:
calculateCart
in interfaceCommerceCartService
- Parameters:
cartModel
- the user's cart in session- Returns:
false
if thecartModel
was already calculated
-
calculateCart
public boolean calculateCart(CommerceCartParameter parameters)
Description copied from interface:CommerceCartService
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.- Specified by:
calculateCart
in interfaceCommerceCartService
- Parameters:
parameters
- the parameter object holding the existingCartModel
that will be calculated- Returns:
false
if thecartModel
was already calculated.
-
recalculateCart
@Deprecated(since="5.2") public void recalculateCart(CartModel cartModel) throws CalculationException
Deprecated.Since 5.2.- Specified by:
recalculateCart
in interfaceCommerceCartService
- Parameters:
cartModel
- the user's cart in session- Throws:
CalculationException
-
recalculateCart
public void recalculateCart(CommerceCartParameter parameters)
Description copied from interface:CommerceCartService
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.- Specified by:
recalculateCart
in interfaceCommerceCartService
- Parameters:
parameters
- A parameter object holding the cart modelCartModel
(must exist) that will be recalculatedCartModel
-
removeAllEntries
@Deprecated(since="5.2") public void removeAllEntries(CartModel cartModel)
Deprecated.Since 5.2.- Specified by:
removeAllEntries
in interfaceCommerceCartService
- Parameters:
cartModel
- the user's cart in session
-
removeAllEntries
public void removeAllEntries(CommerceCartParameter parameter)
Description copied from interface:CommerceCartService
Removes all entries from the givenCartModel
.- Specified by:
removeAllEntries
in interfaceCommerceCartService
- Parameters:
parameter
- A parameter object holding theCartModel
that will be emptied
-
updateQuantityForCartEntry
@Deprecated(since="5.2") public CommerceCartModification updateQuantityForCartEntry(CartModel cartModel, long entryNumber, long newQuantity) throws CommerceCartModificationException
Deprecated.Since 5.2.- Specified by:
updateQuantityForCartEntry
in interfaceCommerceCartService
- Parameters:
cartModel
- the user's cart in sessionentryNumber
- the cart entry numbernewQuantity
- the new quantity- Returns:
- the cart modification
- Throws:
CommerceCartModificationException
-
updateQuantityForCartEntry
public CommerceCartModification updateQuantityForCartEntry(CommerceCartParameter parameters) throws CommerceCartModificationException
Description copied from interface:CommerceCartService
Update quantity for the cart entry with givenentryNumber
with the givennewQuantity
. Then cart is calculated.- Specified by:
updateQuantityForCartEntry
in interfaceCommerceCartService
- Parameters:
parameters
- - 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") public CommerceCartModification updatePointOfServiceForCartEntry(CartModel cartModel, long entryNumber, PointOfServiceModel pointOfServiceModel) throws CommerceCartModificationException
Deprecated.Since 5.2.- Specified by:
updatePointOfServiceForCartEntry
in interfaceCommerceCartService
- Parameters:
cartModel
- the user's cart in sessionentryNumber
- the cart entry numberpointOfServiceModel
- the point of service- Returns:
- the cart modification
- Throws:
CommerceCartModificationException
-
updatePointOfServiceForCartEntry
public CommerceCartModification updatePointOfServiceForCartEntry(CommerceCartParameter parameters) throws CommerceCartModificationException
Description copied from interface:CommerceCartService
Updates given cart entry model with point of service.- Specified by:
updatePointOfServiceForCartEntry
in interfaceCommerceCartService
- 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") public CommerceCartModification updateToShippingModeForCartEntry(CartModel cartModel, long entryNumber) throws CommerceCartModificationException
Deprecated.Since 5.2.- Specified by:
updateToShippingModeForCartEntry
in interfaceCommerceCartService
- Parameters:
cartModel
- the user's cart in sessionentryNumber
- the cart entry number- Returns:
- the cart modification
- Throws:
CommerceCartModificationException
-
updateToShippingModeForCartEntry
public CommerceCartModification updateToShippingModeForCartEntry(CommerceCartParameter parameters) throws CommerceCartModificationException
Description copied from interface:CommerceCartService
Update the shipping mode for a given cart entry- Specified by:
updateToShippingModeForCartEntry
in interfaceCommerceCartService
- 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") public long split(CartModel cartModel, long entryNumber) throws CommerceCartModificationException
Deprecated.Since 5.2.- Specified by:
split
in interfaceCommerceCartService
- Parameters:
cartModel
- the user's cart in sessionentryNumber
- the cart entry number- Returns:
- the number of the newly created entry
- Throws:
CommerceCartModificationException
-
split
public long split(CommerceCartParameter parameters) throws CommerceCartModificationException
Description copied from interface:CommerceCartService
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.- Specified by:
split
in interfaceCommerceCartService
- 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") public CommerceCartRestoration restoreCart(CartModel cartModel) throws CommerceCartRestorationException
Deprecated.Since 5.2.- Specified by:
restoreCart
in interfaceCommerceCartService
- Parameters:
cartModel
- the old cart to restore- Returns:
- details of any items that could not be restored in part or in full
- Throws:
CommerceCartRestorationException
-
restoreCart
public CommerceCartRestoration restoreCart(CommerceCartParameter parameters) throws CommerceCartRestorationException
Description copied from interface:CommerceCartService
Restores the current customer's cart.- Specified by:
restoreCart
in interfaceCommerceCartService
- 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
-
removeStaleCarts
public void removeStaleCarts(CartModel currentCart, BaseSiteModel baseSite, UserModel user)
Description copied from interface:CommerceCartService
Remove the old carts for the user.- Specified by:
removeStaleCarts
in interfaceCommerceCartService
- Parameters:
currentCart
- the current user's cartbaseSite
- the current base siteuser
- the current user
-
removeStaleCarts
public void removeStaleCarts(CommerceCartParameter parameters)
- Specified by:
removeStaleCarts
in interfaceCommerceCartService
- Parameters:
parameters
- a parameter object holding the following values - cart Users Cart - baseSite Current base site - user Current user
-
configureCartEntry
public void configureCartEntry(CommerceCartParameter parameters) throws CommerceCartModificationException
Description copied from interface:CommerceCartService
Update configuration on a configurable product.- Specified by:
configureCartEntry
in interfaceCommerceCartService
- Parameters:
parameters
-cart
entryNumber
product
productConfigurator
productConfiguration
- Throws:
CommerceCartModificationException
- if product is not configurable orentry
is invalid
-
mergeCarts
public void mergeCarts(CartModel fromCart, CartModel toCart, java.util.List<CommerceCartModification> modifications) throws CommerceCartMergingException
Description copied from interface:CommerceCartService
Merge two carts and add modifications- Specified by:
mergeCarts
in interfaceCommerceCartService
- Parameters:
fromCart
- the cart to mergetoCart
- the target cartmodifications
- the list of modifications- Throws:
CommerceCartMergingException
-
getCartForGuidAndSiteAndUser
public CartModel getCartForGuidAndSiteAndUser(java.lang.String guid, BaseSiteModel site, UserModel user)
Description copied from interface:CommerceCartService
Locate a cart for the specified guid and site and user. If guid is null, the most recently modified user cart is returned.- Specified by:
getCartForGuidAndSiteAndUser
in interfaceCommerceCartService
- Parameters:
guid
- a unique identifiersite
- the current BaseSite - may not be nulluser
- the current user - may not be null- Returns:
- the specified cart
-
getCartForGuidAndSite
public CartModel getCartForGuidAndSite(java.lang.String guid, BaseSiteModel site)
Description copied from interface:CommerceCartService
Locate a cart for the specified guid and site- Specified by:
getCartForGuidAndSite
in interfaceCommerceCartService
- Returns:
- the specified cart
-
getCartForCodeAndUser
public CartModel getCartForCodeAndUser(java.lang.String code, UserModel user)
Description copied from interface:CommerceCartService
Locate a cart for the specified guid and site and user.- Specified by:
getCartForCodeAndUser
in interfaceCommerceCartService
- Returns:
- the specified cart
-
getCartsForSiteAndUser
public java.util.List<CartModel> getCartsForSiteAndUser(BaseSiteModel site, UserModel user)
Description copied from interface:CommerceCartService
Locate all carts for the specified site and user.- Specified by:
getCartsForSiteAndUser
in interfaceCommerceCartService
- Returns:
- list of specified carts
-
updateCartMetadata
public void updateCartMetadata(CommerceCartMetadataParameter parameter)
Description copied from interface:CommerceCartService
Updates cart metadata, such as: name, description, expiration time.- Specified by:
updateCartMetadata
in interfaceCommerceCartService
- 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
-
estimateTaxes
public java.math.BigDecimal estimateTaxes(CartModel cartModel, java.lang.String deliveryZipCode, java.lang.String deliveryCountryIso)
Description copied from interface:CommerceCartService
Estimate taxes for the cartModel and using the deliveryZipCode as the delivery zip code.- Specified by:
estimateTaxes
in interfaceCommerceCartService
- 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
public CommerceTaxEstimateResult estimateTaxes(CommerceCartParameter parameters)
Description copied from interface:CommerceCartService
Estimate taxes for the cartModel and using the deliveryZipCode as the delivery zip code.- Specified by:
estimateTaxes
in interfaceCommerceCartService
- 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
-
removeEntryGroup
public CommerceCartModification removeEntryGroup(@Nonnull RemoveEntryGroupParameter parameter) throws CommerceCartModificationException
Description copied from interface:CommerceCartService
Remove entry group and all cart entries of the group and it's descendants from the cart.- Specified by:
removeEntryGroup
in interfaceCommerceCartService
- Parameters:
parameter
- 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.
-
beforeCalculate
@Deprecated(since="5.2") protected void beforeCalculate(CartModel cartModel, boolean recalculate)
Deprecated.Since 5.2. UseCommerceCartCalculationStrategy
before calculation method hooks
-
afterCalculate
@Deprecated(since="5.2") protected void afterCalculate(CartModel cartModel, boolean recalculate)
Deprecated.Since 5.2. UseCommerceCartCalculationStrategy
before calculation method hooks
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getBaseSiteService
protected BaseSiteService getBaseSiteService()
-
setBaseSiteService
public void setBaseSiteService(BaseSiteService baseSiteService)
-
getCommerceCartDao
protected CommerceCartDao getCommerceCartDao()
-
setCommerceCartDao
public void setCommerceCartDao(CommerceCartDao commerceCartDao)
-
getCartValidationStrategy
protected CartValidationStrategy getCartValidationStrategy()
-
setCartValidationStrategy
public void setCartValidationStrategy(CartValidationStrategy cartValidationStrategy)
-
getCommerceCartCalculationStrategy
protected CommerceCartCalculationStrategy getCommerceCartCalculationStrategy()
-
setCommerceCartCalculationStrategy
public void setCommerceCartCalculationStrategy(CommerceCartCalculationStrategy commerceCartCalculationStrategy)
-
getProductConfigurationStrategy
protected CommerceCartProductConfigurationStrategy getProductConfigurationStrategy()
-
setProductConfigurationStrategy
public void setProductConfigurationStrategy(CommerceCartProductConfigurationStrategy productConfigurationStrategy)
-
getSessionService
protected SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
getStaleCartRemovalStrategy
protected StaleCartRemovalStrategy getStaleCartRemovalStrategy()
-
setStaleCartRemovalStrategy
public void setStaleCartRemovalStrategy(StaleCartRemovalStrategy staleCartRemovalStrategy)
-
getCommerceAddToCartStrategy
protected CommerceAddToCartStrategy getCommerceAddToCartStrategy()
-
setCommerceAddToCartStrategy
public void setCommerceAddToCartStrategy(CommerceAddToCartStrategy commerceAddToCartStrategy)
-
getCommerceUpdateCartEntryStrategy
protected CommerceUpdateCartEntryStrategy getCommerceUpdateCartEntryStrategy()
-
setCommerceUpdateCartEntryStrategy
public void setCommerceUpdateCartEntryStrategy(CommerceUpdateCartEntryStrategy commerceUpdateCartEntryStrategy)
-
getCommerceCartHashCalculationStrategy
protected CommerceCartHashCalculationStrategy getCommerceCartHashCalculationStrategy()
-
setCommerceCartHashCalculationStrategy
public void setCommerceCartHashCalculationStrategy(CommerceCartHashCalculationStrategy commerceCartHashCalculationStrategy)
-
getCommerceCartEstimateTaxesStrategy
protected CommerceCartEstimateTaxesStrategy getCommerceCartEstimateTaxesStrategy()
-
setCommerceCartEstimateTaxesStrategy
public void setCommerceCartEstimateTaxesStrategy(CommerceCartEstimateTaxesStrategy commerceCartEstimateTaxesStrategy)
-
getCommerceCartRestorationStrategy
protected CommerceCartRestorationStrategy getCommerceCartRestorationStrategy()
-
setCommerceCartRestorationStrategy
public void setCommerceCartRestorationStrategy(CommerceCartRestorationStrategy commerceCartRestorationStrategy)
-
getCommerceCartMergingStrategy
protected CommerceCartMergingStrategy getCommerceCartMergingStrategy()
-
setCommerceCartMergingStrategy
public void setCommerceCartMergingStrategy(CommerceCartMergingStrategy commerceCartMergingStrategy)
-
getCommerceCartSplitStrategy
protected CommerceCartSplitStrategy getCommerceCartSplitStrategy()
-
setCommerceCartSplitStrategy
public void setCommerceCartSplitStrategy(CommerceCartSplitStrategy commerceCartSplitStrategy)
-
getCommerceRemoveEntriesStrategy
protected CommerceRemoveEntriesStrategy getCommerceRemoveEntriesStrategy()
-
setCommerceRemoveEntriesStrategy
public void setCommerceRemoveEntriesStrategy(CommerceRemoveEntriesStrategy commerceRemoveEntriesStrategy)
-
getCommerceCartMetadataUpdateStrategy
protected CommerceCartMetadataUpdateStrategy getCommerceCartMetadataUpdateStrategy()
-
setCommerceCartMetadataUpdateStrategy
public void setCommerceCartMetadataUpdateStrategy(CommerceCartMetadataUpdateStrategy commerceCartMetadataUpdateStrategy)
-
getRemoveEntryGroupStrategy
protected CommerceRemoveEntryGroupStrategy getRemoveEntryGroupStrategy()
-
setRemoveEntryGroupStrategy
public void setRemoveEntryGroupStrategy(CommerceRemoveEntryGroupStrategy removeEntryGroupStrategy)
-
-