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 CartModificationData
addToCart(AddToCartParams addToCartParams)
Method for adding a product to cart.CartModificationData
addToCart(java.lang.String code, long quantity)
Method for adding a product to cart.CartModificationData
addToCart(java.lang.String code, long quantity, java.lang.String storeId)
Method for adding a product to cart.protected ProductConfigurationItem
configurationInfoToProductConfiguration(ConfigurationInfoData configurationInfoData)
protected CartModificationData
configureCartEntry(OrderEntryData orderEntry, CartModificationData cartModificationData)
protected CommerceCartParameter
createCommerceCartParameter(OrderEntryData orderEntry, java.util.List<ProductConfigurationItem> productConfigurationItemList)
protected CartData
createEmptyCart()
protected CartModificationData
deleteGroupedOrderEntriesMultiD(OrderEntryData orderEntry)
CartData
estimateExternalTaxes(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 BaseSiteService
getBaseSiteService()
protected Converter<CartModel,CartData>
getCartConverter()
protected Converter<CommerceCartModification,CartModificationData>
getCartModificationConverter()
protected Converter<CommerceCartRestoration,CartRestorationData>
getCartRestorationConverter()
protected CartService
getCartService()
java.util.List<CartData>
getCartsForCurrentUser()
Returns all carts for current site and user.protected Converter<AddToCartParams,CommerceCartParameter>
getCommerceCartParameterConverter()
protected CommerceCartService
getCommerceCartService()
Converter<CountryModel,CountryData>
getCountryConverter()
java.util.List<CountryData>
getDeliveryCountries()
Deprecated.since 1808.DeliveryService
getDeliveryService()
Converter<AbstractOrderModel,java.util.List<CartModificationData>>
getGroupCartModificationListConverter()
CartData
getMiniCart()
Method gets smaller version of cart, with data necessary for showing mini cart.protected Converter<CartModel,CartData>
getMiniCartConverter()
protected ModelService
getModelService()
java.lang.String
getMostRecentCartGuidForUser(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.Integer
getOrderEntryNumberForMultiD(OrderEntryData findEntry)
protected PointOfServiceService
getPointOfServiceService()
PriceDataFactory
getPriceDataFactory()
protected java.util.Map<ConfiguratorType,ProductConfigurationMergeStrategy>
getProductConfigurationMergeStrategies()
protected ProductFacade
getProductFacade()
protected ProductService
getProductService()
CartData
getSessionCart()
Method gets cart from session, if any exist.java.lang.String
getSessionCartGuid()
Returns session cart guid if any.CartData
getSessionCartWithEntryOrdering(boolean recentlyAddedFirst)
Method gets cart sorted by recently added entries from session, if param is set to trueprotected UserService
getUserService()
boolean
hasEntries()
Check if session cart has entries, avoiding full conversion of the cart to CartData.protected boolean
hasEntryGroups()
boolean
hasSessionCart()
Check if session has a cart.protected void
mergeOrderEntryWithModelConfiguration(OrderEntryData orderEntry)
CartModificationData
removeEntryGroup(java.lang.Integer groupNumber)
Removes group with all subsequent entries.void
removeSessionCart()
If existing the current session cart is being detached from this session and removed.void
removeStaleCarts()
Remove the stale carts of the current user.CartRestorationData
restoreAnonymousCartAndMerge(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.CartRestorationData
restoreAnonymousCartAndTakeOwnership(java.lang.String guid)
Restores the anonymous user's cart to the session and sets its user to current user.CartRestorationData
restoreCartAndMerge(java.lang.String fromUserCartGuid, java.lang.String toUserCartGuid)
Merges user's carts, restores merged cart to the session, sets its user to current user.CartRestorationData
restoreSavedCart(java.lang.String guid)
Restores the user's saved cart to the session.void
setBaseSiteService(BaseSiteService baseSiteService)
void
setCartConverter(Converter<CartModel,CartData> cartConverter)
void
setCartModificationConverter(Converter<CommerceCartModification,CartModificationData> cartModificationConverter)
void
setCartRestorationConverter(Converter<CommerceCartRestoration,CartRestorationData> cartRestorationConverter)
void
setCartService(CartService cartService)
void
setCommerceCartParameterConverter(Converter<AddToCartParams,CommerceCartParameter> commerceCartParameterConverter)
void
setCommerceCartService(CommerceCartService commerceCartService)
void
setCountryConverter(Converter<CountryModel,CountryData> countryConverter)
void
setDeliveryService(DeliveryService deliveryService)
void
setGroupCartModificationListConverter(Converter<AbstractOrderModel,java.util.List<CartModificationData>> groupCartModificationListConverter)
void
setMiniCartConverter(Converter<CartModel,CartData> miniCartConverter)
void
setModelService(ModelService modelService)
void
setOrderEntryConverter(Converter<AbstractOrderEntryModel,OrderEntryData> orderEntryConverter)
void
setPointOfServiceService(PointOfServiceService pointOfServiceService)
void
setPriceDataFactory(PriceDataFactory priceDataFactory)
void
setProductConfigurationMergeStrategies(java.util.Map<ConfiguratorType,ProductConfigurationMergeStrategy> productConfigurationMergeStrategies)
void
setProductFacade(ProductFacade productFacade)
void
setProductService(ProductService productService)
void
setUserService(UserService userService)
CartModificationData
updateCartEntry(long entryNumber, long quantity)
Method for updating the number of products.CartModificationData
updateCartEntry(long entryNumber, java.lang.String storeId)
Method for updating the number of products.CartModificationData
updateCartEntry(OrderEntryData orderEntry)
Updates the given cart entry.void
updateCartMetadata(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:CartFacade
Method gets cart from session, if any exist.- Specified by:
getSessionCart
in interfaceCartFacade
- Returns:
- the cart data
-
getSessionCartGuid
public java.lang.String getSessionCartGuid()
Description copied from interface:CartFacade
Returns session cart guid if any.- Specified by:
getSessionCartGuid
in interfaceCartFacade
- Returns:
- the session cart guid
-
getMiniCart
public CartData getMiniCart()
Description copied from interface:CartFacade
Method gets smaller version of cart, with data necessary for showing mini cart.- Specified by:
getMiniCart
in interfaceCartFacade
- Returns:
- the mini card data
-
createEmptyCart
protected CartData createEmptyCart()
-
hasSessionCart
public boolean hasSessionCart()
Description copied from interface:CartFacade
Check if session has a cart.- Specified by:
hasSessionCart
in interfaceCartFacade
- Returns:
- true if the session has a cart
-
hasEntries
public boolean hasEntries()
Description copied from interface:CartFacade
Check if session cart has entries, avoiding full conversion of the cart to CartData. For Performance.- Specified by:
hasEntries
in 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:CartFacade
Method for adding a product to cart.- Specified by:
addToCart
in 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:CartFacade
Method for adding a product to cart.- Specified by:
addToCart
in 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:CartFacade
Method for adding a product to cart.- Specified by:
addToCart
in 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:CartFacade
Method for validating every entry in the cart- Specified by:
validateCartData
in 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:CartFacade
Method for updating the number of products.- Specified by:
updateCartEntry
in 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:CartFacade
Method for updating the number of products.- Specified by:
updateCartEntry
in 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:CartFacade
Restores 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:
restoreSavedCart
in 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:CartFacade
Restores the anonymous user's cart to the session and sets its user to current user.- Specified by:
restoreAnonymousCartAndTakeOwnership
in 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:CartFacade
Merges carts from anonymous to given user's cart, restores user's cart to the session, sets its user to current user.- Specified by:
restoreAnonymousCartAndMerge
in interfaceCartFacade
- Parameters:
fromAnonymousCartGuid
- - Anonymous user's cart from merging is donetoUserCartGuid
- - User's cart to merge to- Returns:
CartRestorationData
object holding information about the restoration- Throws:
CommerceCartRestorationException
CommerceCartMergingException
-
restoreCartAndMerge
public CartRestorationData restoreCartAndMerge(java.lang.String fromUserCartGuid, java.lang.String toUserCartGuid) throws CommerceCartRestorationException, CommerceCartMergingException
Description copied from interface:CartFacade
Merges user's carts, restores merged cart to the session, sets its user to current user.- Specified by:
restoreCartAndMerge
in interfaceCartFacade
- Parameters:
fromUserCartGuid
- - User's cart from merging is donetoUserCartGuid
- - User's cart to merge to- Returns:
CartRestorationData
object holding information about the restoration- Throws:
CommerceCartRestorationException
CommerceCartMergingException
-
removeStaleCarts
public void removeStaleCarts()
Description copied from interface:CartFacade
Remove the stale carts of the current user.- Specified by:
removeStaleCarts
in interfaceCartFacade
-
estimateExternalTaxes
public CartData estimateExternalTaxes(java.lang.String deliveryZipCode, java.lang.String countryIsoCode)
Description copied from interface:CartFacade
Estimate taxes on the cart.- Specified by:
estimateExternalTaxes
in 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:CartFacade
Method gets cart sorted by recently added entries from session, if param is set to true- Specified by:
getSessionCartWithEntryOrdering
in 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:CartFacade
Get the supported delivery countries. The list is sorted alphabetically.- Specified by:
getDeliveryCountries
in interfaceCartFacade
- Returns:
- list of supported delivery countries.
-
removeSessionCart
public void removeSessionCart()
Description copied from interface:CartFacade
If existing the current session cart is being detached from this session and removed. Afterwards it's no longer available.- Specified by:
removeSessionCart
in interfaceCartFacade
-
getCartsForCurrentUser
public java.util.List<CartData> getCartsForCurrentUser()
Description copied from interface:CartFacade
Returns all carts for current site and user.- Specified by:
getCartsForCurrentUser
in interfaceCartFacade
- Returns:
- list of carts
-
getMostRecentCartGuidForUser
public java.lang.String getMostRecentCartGuidForUser(java.util.Collection<java.lang.String> excludedCartGuid)
Description copied from interface:CartFacade
Returns most recent cart guid for current site and user excluding the list of carts guid passed.- Specified by:
getMostRecentCartGuidForUser
in interfaceCartFacade
- Parameters:
excludedCartGuid
- the excluded carts guid- Returns:
- the cart guid
-
updateCartMetadata
public void updateCartMetadata(CommerceCartMetadata metadata)
Description copied from interface:CartFacade
Updates cart metadata, such as: name, description, expiration time.- Specified by:
updateCartMetadata
in 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:CartFacade
Updates the given cart entry.- Specified by:
updateCartEntry
in 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:CartFacade
Removes group with all subsequent entries.- Specified by:
removeEntryGroup
in 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)
-
-