Class DefaultCartFacade
- java.lang.Object
-
- de.hybris.platform.commercefacades.order.impl.DefaultCartFacade
-
- All Implemented Interfaces:
CartFacade
- Direct Known Subclasses:
CommerceWebServicesCartFacade,DefaultCartFacade,DefaultSapCartFacade,DefaultSaveCartFacade
public class DefaultCartFacade extends java.lang.Object implements CartFacade
Implementation forCartFacade. Delivers main functionality for cart.
-
-
Constructor Summary
Constructors Constructor Description DefaultCartFacade()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CartModificationDataaddToCart(AddToCartParams addToCartParams)Method for adding a product to cart.CartModificationDataaddToCart(java.lang.String code, long quantity)Method for adding a product to cart.CartModificationDataaddToCart(java.lang.String code, long quantity, java.lang.String storeId)Method for adding a product to cart.protected ProductConfigurationItemconfigurationInfoToProductConfiguration(ConfigurationInfoData configurationInfoData)protected CartModificationDataconfigureCartEntry(OrderEntryData orderEntry, CartModificationData cartModificationData)protected CommerceCartParametercreateCommerceCartParameter(OrderEntryData orderEntry, java.util.List<ProductConfigurationItem> productConfigurationItemList)protected CartDatacreateEmptyCart()protected CartModificationDatadeleteGroupedOrderEntriesMultiD(OrderEntryData orderEntry)CartDataestimateExternalTaxes(java.lang.String deliveryZipCode, java.lang.String countryIsoCode)Estimate taxes on the cart.protected java.util.List<ConfigurationInfoData>filterConfigurationsByConfigurator(java.util.List<ConfigurationInfoData> configurations, ConfiguratorType configuratorEnum)protected BaseSiteServicegetBaseSiteService()protected Converter<CartModel,CartData>getCartConverter()protected Converter<CommerceCartModification,CartModificationData>getCartModificationConverter()protected Converter<CommerceCartRestoration,CartRestorationData>getCartRestorationConverter()protected CartServicegetCartService()java.util.List<CartData>getCartsForCurrentUser()Returns all carts for current site and user.protected Converter<AddToCartParams,CommerceCartParameter>getCommerceCartParameterConverter()protected CommerceCartServicegetCommerceCartService()Converter<CountryModel,CountryData>getCountryConverter()java.util.List<CountryData>getDeliveryCountries()Deprecated.since 1808.DeliveryServicegetDeliveryService()Converter<AbstractOrderModel,java.util.List<CartModificationData>>getGroupCartModificationListConverter()CartDatagetMiniCart()Method gets smaller version of cart, with data necessary for showing mini cart.protected Converter<CartModel,CartData>getMiniCartConverter()protected ModelServicegetModelService()java.lang.StringgetMostRecentCartGuidForUser(java.util.Collection<java.lang.String> excludedCartGuid)Returns most recent cart guid for current site and user excluding the list of carts guid passed.protected Converter<AbstractOrderEntryModel,OrderEntryData>getOrderEntryConverter()protected java.lang.IntegergetOrderEntryNumberForMultiD(OrderEntryData findEntry)protected PointOfServiceServicegetPointOfServiceService()PriceDataFactorygetPriceDataFactory()protected java.util.Map<ConfiguratorType,ProductConfigurationMergeStrategy>getProductConfigurationMergeStrategies()protected ProductFacadegetProductFacade()protected ProductServicegetProductService()CartDatagetSessionCart()Method gets cart from session, if any exist.java.lang.StringgetSessionCartGuid()Returns session cart guid if any.CartDatagetSessionCartWithEntryOrdering(boolean recentlyAddedFirst)Method gets cart sorted by recently added entries from session, if param is set to trueprotected UserServicegetUserService()booleanhasEntries()Check if session cart has entries, avoiding full conversion of the cart to CartData.protected booleanhasEntryGroups()booleanhasSessionCart()Check if session has a cart.protected voidmergeOrderEntryWithModelConfiguration(OrderEntryData orderEntry)CartModificationDataremoveEntryGroup(java.lang.Integer groupNumber)Removes group with all subsequent entries.voidremoveSessionCart()If existing the current session cart is being detached from this session and removed.voidremoveStaleCarts()Remove the stale carts of the current user.CartRestorationDatarestoreAnonymousCartAndMerge(java.lang.String fromAnonymousCartGuid, java.lang.String toUserCartGuid)Merges carts from anonymous to given user's cart, restores user's cart to the session, sets its user to current user.CartRestorationDatarestoreAnonymousCartAndTakeOwnership(java.lang.String guid)Restores the anonymous user's cart to the session and sets its user to current user.CartRestorationDatarestoreCartAndMerge(java.lang.String fromUserCartGuid, java.lang.String toUserCartGuid)Merges user's carts, restores merged cart to the session, sets its user to current user.CartRestorationDatarestoreSavedCart(java.lang.String guid)Restores the user's saved cart to the session.voidsetBaseSiteService(BaseSiteService baseSiteService)voidsetCartConverter(Converter<CartModel,CartData> cartConverter)voidsetCartModificationConverter(Converter<CommerceCartModification,CartModificationData> cartModificationConverter)voidsetCartRestorationConverter(Converter<CommerceCartRestoration,CartRestorationData> cartRestorationConverter)voidsetCartService(CartService cartService)voidsetCommerceCartParameterConverter(Converter<AddToCartParams,CommerceCartParameter> commerceCartParameterConverter)voidsetCommerceCartService(CommerceCartService commerceCartService)voidsetCountryConverter(Converter<CountryModel,CountryData> countryConverter)voidsetDeliveryService(DeliveryService deliveryService)voidsetGroupCartModificationListConverter(Converter<AbstractOrderModel,java.util.List<CartModificationData>> groupCartModificationListConverter)voidsetMiniCartConverter(Converter<CartModel,CartData> miniCartConverter)voidsetModelService(ModelService modelService)voidsetOrderEntryConverter(Converter<AbstractOrderEntryModel,OrderEntryData> orderEntryConverter)voidsetPointOfServiceService(PointOfServiceService pointOfServiceService)voidsetPriceDataFactory(PriceDataFactory priceDataFactory)voidsetProductConfigurationMergeStrategies(java.util.Map<ConfiguratorType,ProductConfigurationMergeStrategy> productConfigurationMergeStrategies)voidsetProductFacade(ProductFacade productFacade)voidsetProductService(ProductService productService)voidsetUserService(UserService userService)CartModificationDataupdateCartEntry(long entryNumber, long quantity)Method for updating the number of products.CartModificationDataupdateCartEntry(long entryNumber, java.lang.String storeId)Method for updating the number of products.CartModificationDataupdateCartEntry(OrderEntryData orderEntry)Updates the given cart entry.voidupdateCartMetadata(CommerceCartMetadata metadata)Updates cart metadata, such as: name, description, expiration time.java.util.List<CartModificationData>validateCartData()Method for validating every entry in the cart
-
-
-
Method Detail
-
getSessionCart
public CartData getSessionCart()
Description copied from interface:CartFacadeMethod gets cart from session, if any exist.- Specified by:
getSessionCartin interfaceCartFacade- Returns:
- the cart data
-
getSessionCartGuid
public java.lang.String getSessionCartGuid()
Description copied from interface:CartFacadeReturns session cart guid if any.- Specified by:
getSessionCartGuidin interfaceCartFacade- Returns:
- the session cart guid
-
getMiniCart
public CartData getMiniCart()
Description copied from interface:CartFacadeMethod gets smaller version of cart, with data necessary for showing mini cart.- Specified by:
getMiniCartin interfaceCartFacade- Returns:
- the mini card data
-
createEmptyCart
protected CartData createEmptyCart()
-
hasSessionCart
public boolean hasSessionCart()
Description copied from interface:CartFacadeCheck if session has a cart.- Specified by:
hasSessionCartin interfaceCartFacade- Returns:
- true if the session has a cart
-
hasEntries
public boolean hasEntries()
Description copied from interface:CartFacadeCheck if session cart has entries, avoiding full conversion of the cart to CartData. For Performance.- Specified by:
hasEntriesin interfaceCartFacade- Returns:
- true if the cart has any entries.
-
addToCart
public CartModificationData addToCart(java.lang.String code, long quantity) throws CommerceCartModificationException
Description copied from interface:CartFacadeMethod for adding a product to cart.- Specified by:
addToCartin interfaceCartFacade- Parameters:
code- code of product to addquantity- the quantity of the product- Returns:
- the cart modification data that includes a statusCode and the actual quantity added to the cart
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
addToCart
public CartModificationData addToCart(java.lang.String code, long quantity, java.lang.String storeId) throws CommerceCartModificationException
Description copied from interface:CartFacadeMethod for adding a product to cart.- Specified by:
addToCartin interfaceCartFacade- Parameters:
code- code of product to addquantity- the quantity of the productstoreId- The identifier for the store. If null {@see CartFacade#addToCart(String, long)} is used.- Returns:
- the cart modification data that includes a statusCode and the actual quantity added to the cart
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
addToCart
public CartModificationData addToCart(AddToCartParams addToCartParams) throws CommerceCartModificationException
Description copied from interface:CartFacadeMethod for adding a product to cart.- Specified by:
addToCartin interfaceCartFacade- Parameters:
addToCartParams- addToCartParams- Returns:
- the cart modification data that includes a statusCode and the actual quantity added to the cart
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
validateCartData
public java.util.List<CartModificationData> validateCartData() throws CommerceCartModificationException
Description copied from interface:CartFacadeMethod for validating every entry in the cart- Specified by:
validateCartDatain interfaceCartFacade- Returns:
- a list of cart modifications that includes a statusCode and the actual quantity that the entry was updated to
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
updateCartEntry
public CartModificationData updateCartEntry(long entryNumber, long quantity) throws CommerceCartModificationException
Description copied from interface:CartFacadeMethod for updating the number of products.- Specified by:
updateCartEntryin interfaceCartFacade- Parameters:
entryNumber- the entry numberquantity- new value of quantity for product- Returns:
- the cart modification data that includes a statusCode and the actual quantity that the entry was updated to
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
updateCartEntry
public CartModificationData updateCartEntry(long entryNumber, java.lang.String storeId) throws CommerceCartModificationException
Description copied from interface:CartFacadeMethod for updating the number of products.- Specified by:
updateCartEntryin interfaceCartFacade- Parameters:
entryNumber- The entry numberstoreId- The identifier for the store. Can be null.- Returns:
- the cart modification data that includes a statusCode and the actual quantity that the entry was updated to
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
restoreSavedCart
public CartRestorationData restoreSavedCart(java.lang.String guid) throws CommerceCartRestorationException
Description copied from interface:CartFacadeRestores the user's saved cart to the session. For non-anonymous users, the cart restored will be for the current user and site.- Specified by:
restoreSavedCartin interfaceCartFacade- Parameters:
guid- the cart guid to restore for Anonymous user.- Returns:
- the cart restoration data that includes details of any items that could not be restored in part or in full.
- Throws:
CommerceCartRestorationException
-
restoreAnonymousCartAndTakeOwnership
public CartRestorationData restoreAnonymousCartAndTakeOwnership(java.lang.String guid) throws CommerceCartRestorationException
Description copied from interface:CartFacadeRestores the anonymous user's cart to the session and sets its user to current user.- Specified by:
restoreAnonymousCartAndTakeOwnershipin interfaceCartFacade- Parameters:
guid- GUID used to find anonymous user's cart- Returns:
- the cart restoration data that includes details of any items that could not be restored in part or in full.
- Throws:
CommerceCartRestorationException
-
restoreAnonymousCartAndMerge
public CartRestorationData restoreAnonymousCartAndMerge(java.lang.String fromAnonymousCartGuid, java.lang.String toUserCartGuid) throws CommerceCartRestorationException, CommerceCartMergingException
Description copied from interface:CartFacadeMerges carts from anonymous to given user's cart, restores user's cart to the session, sets its user to current user.- Specified by:
restoreAnonymousCartAndMergein interfaceCartFacade- Parameters:
fromAnonymousCartGuid- - Anonymous user's cart from merging is donetoUserCartGuid- - User's cart to merge to- Returns:
CartRestorationDataobject holding information about the restoration- Throws:
CommerceCartRestorationExceptionCommerceCartMergingException
-
restoreCartAndMerge
public CartRestorationData restoreCartAndMerge(java.lang.String fromUserCartGuid, java.lang.String toUserCartGuid) throws CommerceCartRestorationException, CommerceCartMergingException
Description copied from interface:CartFacadeMerges user's carts, restores merged cart to the session, sets its user to current user.- Specified by:
restoreCartAndMergein interfaceCartFacade- Parameters:
fromUserCartGuid- - User's cart from merging is donetoUserCartGuid- - User's cart to merge to- Returns:
CartRestorationDataobject holding information about the restoration- Throws:
CommerceCartRestorationExceptionCommerceCartMergingException
-
removeStaleCarts
public void removeStaleCarts()
Description copied from interface:CartFacadeRemove the stale carts of the current user.- Specified by:
removeStaleCartsin interfaceCartFacade
-
estimateExternalTaxes
public CartData estimateExternalTaxes(java.lang.String deliveryZipCode, java.lang.String countryIsoCode)
Description copied from interface:CartFacadeEstimate taxes on the cart.- Specified by:
estimateExternalTaxesin interfaceCartFacade- Parameters:
deliveryZipCode- delivery zip code used for calculating external taxescountryIsoCode- delivery country used for calculating taxes- Returns:
- cart data that represents the current cart with taxes estimations added
-
getSessionCartWithEntryOrdering
public CartData getSessionCartWithEntryOrdering(boolean recentlyAddedFirst)
Description copied from interface:CartFacadeMethod gets cart sorted by recently added entries from session, if param is set to true- Specified by:
getSessionCartWithEntryOrderingin interfaceCartFacade- Parameters:
recentlyAddedFirst- boolean value to determine whether to return sorted cart data- Returns:
- the cart data sorted by recently added entries
-
getDeliveryCountries
@Deprecated(since="1808") public java.util.List<CountryData> getDeliveryCountries()
Deprecated.since 1808. Please useCheckoutFacade.getCountries(CountryType)instead.Description copied from interface:CartFacadeGet the supported delivery countries. The list is sorted alphabetically.- Specified by:
getDeliveryCountriesin interfaceCartFacade- Returns:
- list of supported delivery countries.
-
removeSessionCart
public void removeSessionCart()
Description copied from interface:CartFacadeIf existing the current session cart is being detached from this session and removed. Afterwards it's no longer available.- Specified by:
removeSessionCartin interfaceCartFacade
-
getCartsForCurrentUser
public java.util.List<CartData> getCartsForCurrentUser()
Description copied from interface:CartFacadeReturns all carts for current site and user.- Specified by:
getCartsForCurrentUserin interfaceCartFacade- Returns:
- list of carts
-
getMostRecentCartGuidForUser
public java.lang.String getMostRecentCartGuidForUser(java.util.Collection<java.lang.String> excludedCartGuid)
Description copied from interface:CartFacadeReturns most recent cart guid for current site and user excluding the list of carts guid passed.- Specified by:
getMostRecentCartGuidForUserin interfaceCartFacade- Parameters:
excludedCartGuid- the excluded carts guid- Returns:
- the cart guid
-
updateCartMetadata
public void updateCartMetadata(CommerceCartMetadata metadata)
Description copied from interface:CartFacadeUpdates cart metadata, such as: name, description, expiration time.- Specified by:
updateCartMetadatain interfaceCartFacade- Parameters:
metadata- a bean holding parameters a client may want to pass to the method, attributes can be added to the bean via beans.xml in your extensions
-
updateCartEntry
public CartModificationData updateCartEntry(OrderEntryData orderEntry) throws CommerceCartModificationException
Description copied from interface:CartFacadeUpdates the given cart entry.- Specified by:
updateCartEntryin interfaceCartFacade- Parameters:
orderEntry- the order entry data object identifying the order entry to update and holding the updated attributes.- Returns:
- the cart modification data that includes a statusCode and the actual quantity that the entry was updated
- Throws:
CommerceCartModificationException
-
removeEntryGroup
public CartModificationData removeEntryGroup(@Nonnull java.lang.Integer groupNumber) throws CommerceCartModificationException
Description copied from interface:CartFacadeRemoves group with all subsequent entries.- Specified by:
removeEntryGroupin interfaceCartFacade- Parameters:
groupNumber- group number- Returns:
- cart modification data with status code: "invalidGroupNumber" - group not found, "notPermitted" - group can not be removed, null - OK
- Throws:
CommerceCartModificationException
-
mergeOrderEntryWithModelConfiguration
protected void mergeOrderEntryWithModelConfiguration(OrderEntryData orderEntry)
-
filterConfigurationsByConfigurator
protected java.util.List<ConfigurationInfoData> filterConfigurationsByConfigurator(java.util.List<ConfigurationInfoData> configurations, ConfiguratorType configuratorEnum)
-
configureCartEntry
protected CartModificationData configureCartEntry(OrderEntryData orderEntry, CartModificationData cartModificationData) throws CommerceCartModificationException
-
deleteGroupedOrderEntriesMultiD
protected CartModificationData deleteGroupedOrderEntriesMultiD(OrderEntryData orderEntry) throws CommerceCartModificationException
-
getOrderEntryNumberForMultiD
protected java.lang.Integer getOrderEntryNumberForMultiD(OrderEntryData findEntry)
-
configurationInfoToProductConfiguration
protected ProductConfigurationItem configurationInfoToProductConfiguration(ConfigurationInfoData configurationInfoData)
-
createCommerceCartParameter
protected CommerceCartParameter createCommerceCartParameter(OrderEntryData orderEntry, java.util.List<ProductConfigurationItem> productConfigurationItemList)
-
hasEntryGroups
protected boolean hasEntryGroups()
-
getCartService
protected CartService getCartService()
-
setCartService
public void setCartService(CartService cartService)
-
setMiniCartConverter
public void setMiniCartConverter(Converter<CartModel,CartData> miniCartConverter)
-
getProductService
protected ProductService getProductService()
-
setProductService
public void setProductService(ProductService productService)
-
getCommerceCartService
protected CommerceCartService getCommerceCartService()
-
setCommerceCartService
public void setCommerceCartService(CommerceCartService commerceCartService)
-
getCartModificationConverter
protected Converter<CommerceCartModification,CartModificationData> getCartModificationConverter()
-
setCartModificationConverter
public void setCartModificationConverter(Converter<CommerceCartModification,CartModificationData> cartModificationConverter)
-
getCartRestorationConverter
protected Converter<CommerceCartRestoration,CartRestorationData> getCartRestorationConverter()
-
setCartRestorationConverter
public void setCartRestorationConverter(Converter<CommerceCartRestoration,CartRestorationData> cartRestorationConverter)
-
getBaseSiteService
protected BaseSiteService getBaseSiteService()
-
setBaseSiteService
public void setBaseSiteService(BaseSiteService baseSiteService)
-
getUserService
protected UserService getUserService()
-
setUserService
public void setUserService(UserService userService)
-
getProductFacade
protected ProductFacade getProductFacade()
-
setProductFacade
public void setProductFacade(ProductFacade productFacade)
-
getPointOfServiceService
protected PointOfServiceService getPointOfServiceService()
-
setPointOfServiceService
public void setPointOfServiceService(PointOfServiceService pointOfServiceService)
-
getPriceDataFactory
public PriceDataFactory getPriceDataFactory()
-
setPriceDataFactory
public void setPriceDataFactory(PriceDataFactory priceDataFactory)
-
getDeliveryService
public DeliveryService getDeliveryService()
-
setDeliveryService
public void setDeliveryService(DeliveryService deliveryService)
-
getCountryConverter
public Converter<CountryModel,CountryData> getCountryConverter()
-
setCountryConverter
public void setCountryConverter(Converter<CountryModel,CountryData> countryConverter)
-
getGroupCartModificationListConverter
public Converter<AbstractOrderModel,java.util.List<CartModificationData>> getGroupCartModificationListConverter()
-
getOrderEntryConverter
protected Converter<AbstractOrderEntryModel,OrderEntryData> getOrderEntryConverter()
-
setOrderEntryConverter
public void setOrderEntryConverter(Converter<AbstractOrderEntryModel,OrderEntryData> orderEntryConverter)
-
setGroupCartModificationListConverter
public void setGroupCartModificationListConverter(Converter<AbstractOrderModel,java.util.List<CartModificationData>> groupCartModificationListConverter)
-
getProductConfigurationMergeStrategies
protected java.util.Map<ConfiguratorType,ProductConfigurationMergeStrategy> getProductConfigurationMergeStrategies()
-
setProductConfigurationMergeStrategies
public void setProductConfigurationMergeStrategies(java.util.Map<ConfiguratorType,ProductConfigurationMergeStrategy> productConfigurationMergeStrategies)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getCommerceCartParameterConverter
protected Converter<AddToCartParams,CommerceCartParameter> getCommerceCartParameterConverter()
-
setCommerceCartParameterConverter
public void setCommerceCartParameterConverter(Converter<AddToCartParams,CommerceCartParameter> commerceCartParameterConverter)
-
-