Class ReplaceCartMergingStrategy
java.lang.Object
de.hybris.platform.commerceservices.order.impl.AbstractCommerceCartStrategy
de.hybris.platform.travelservices.order.impl.ReplaceCartMergingStrategy
- All Implemented Interfaces:
de.hybris.platform.commerceservices.order.impl.CommerceCartMergingStrategy
public class ReplaceCartMergingStrategy
extends de.hybris.platform.commerceservices.order.impl.AbstractCommerceCartStrategy
implements de.hybris.platform.commerceservices.order.impl.CommerceCartMergingStrategy
This is a drop-in replacement for the standard commerce cart merging strategy and has taken the code from the current
hybris 5.5 release version and made a simple modification to allow the developer to chose whether the merge should
actually take place, or whether the cart manipulation (when handling the change from an anonymous cart to a
previously saved cart for a user) should simply override the new logic. This is because prior to Hybris 5.3, the
anonymous cart would overwrite the infomation in the user's previously saved cart when logging in. The Travel
Services accelerator needs this behaviour to remain in place (and others may also depend on this behaviour). Ideally,
this approach will be adopted in the future and this code can be removed from this extension and merely configure the
correct component. At the very least, it needs tidying up before actual release so that we are using more protected
methods so that we can override / extend as necessary
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class de.hybris.platform.commerceservices.order.impl.AbstractCommerceCartStrategy
DEFAULT_FORCE_IN_STOCK_MAX_QUANTITY, forceInStockMaxQuantity -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfinaliseFromCart(CartModel fromCart) After cart merge, the system should handle the fromCart, if the mergeAction is OVERWRITE, it check if the cart that was retrieved by system, from the Customer's cart list, is saved explicitly or it's and abandon cart that can be discard.protected de.hybris.platform.site.BaseSiteServiceGets base site service.protected de.hybris.platform.commerceservices.order.CommerceAddToCartStrategyGets commerce add to cart strategy.protected de.hybris.platform.commerceservices.order.CommerceCartServiceGets commerce cart service.protected ReplaceCartMergingStrategy.MergeActionGets merge action.protected de.hybris.platform.servicelayer.user.UserServiceGets user service.voidmergeCarts(CartModel fromCart, CartModel toCart, List<CommerceCartModification> modifications) protected voidmergeModificationToList(CommerceCartModification modificationToAdd, List<CommerceCartModification> toModificationList) Merge modification to list.protected StringmergeStatusCodes(String statusCode, String statusCode1) Merge status codes string.voidsetBaseSiteService(de.hybris.platform.site.BaseSiteService baseSiteService) Sets base site service.voidsetCommerceAddToCartStrategy(de.hybris.platform.commerceservices.order.CommerceAddToCartStrategy commerceAddToCartStrategy) Sets commerce add to cart strategy.voidsetCommerceCartService(de.hybris.platform.commerceservices.order.CommerceCartService commerceCartService) Sets commerce cart service.voidsetMergeAction(ReplaceCartMergingStrategy.MergeAction mergeAction) Sets merge action.voidsetUserService(de.hybris.platform.servicelayer.user.UserService userService) Sets user service.Methods inherited from class de.hybris.platform.commerceservices.order.impl.AbstractCommerceCartStrategy
checkCartLevel, getAllowedCartAdjustmentForProduct, getAvailableStockLevel, getBaseStoreService, getCartEntryDao, getCartService, getCommerceCartCalculationStrategy, getCommerceStockService, getEntryForNumber, getEntryForProductAndPointOfService, getEntryOrderChecker, getForceInStockMaxQuantity, getModelService, getProductService, isMaxOrderQuantitySet, isOrderEntryUpdatable, isStockLevelSufficient, normalizeEntryNumbers, setBaseStoreService, setCartEntryDao, setCartService, setCommerceCartCalculationStrategy, setCommerceStockService, setEntryOrderChecker, setForceInStockMaxQuantity, setModelService, setProductService
-
Constructor Details
-
ReplaceCartMergingStrategy
public ReplaceCartMergingStrategy()
-
-
Method Details
-
mergeCarts
public void mergeCarts(CartModel fromCart, CartModel toCart, List<CommerceCartModification> modifications) throws de.hybris.platform.commerceservices.order.CommerceCartMergingException - Specified by:
mergeCartsin interfacede.hybris.platform.commerceservices.order.impl.CommerceCartMergingStrategy- Throws:
de.hybris.platform.commerceservices.order.CommerceCartMergingException
-
finaliseFromCart
After cart merge, the system should handle the fromCart, if the mergeAction is OVERWRITE, it check if the cart that was retrieved by system, from the Customer's cart list, is saved explicitly or it's and abandon cart that can be discard.- Parameters:
fromCart- the from cart
-
mergeModificationToList
protected void mergeModificationToList(CommerceCartModification modificationToAdd, List<CommerceCartModification> toModificationList) Merge modification to list.- Parameters:
modificationToAdd- the modification to addtoModificationList- the to modification list
-
mergeStatusCodes
Merge status codes string.- Parameters:
statusCode- the status codestatusCode1- the status code 1- Returns:
- the string
-
getUserService
protected de.hybris.platform.servicelayer.user.UserService getUserService()Gets user service.- Returns:
- the user service
-
setUserService
public void setUserService(de.hybris.platform.servicelayer.user.UserService userService) Sets user service.- Parameters:
userService- the user service
-
getCommerceCartService
protected de.hybris.platform.commerceservices.order.CommerceCartService getCommerceCartService()Gets commerce cart service.- Returns:
- the commerce cart service
-
setCommerceCartService
public void setCommerceCartService(de.hybris.platform.commerceservices.order.CommerceCartService commerceCartService) Sets commerce cart service.- Parameters:
commerceCartService- the commerce cart service
-
getBaseSiteService
protected de.hybris.platform.site.BaseSiteService getBaseSiteService()Gets base site service.- Returns:
- the base site service
-
setBaseSiteService
public void setBaseSiteService(de.hybris.platform.site.BaseSiteService baseSiteService) Sets base site service.- Parameters:
baseSiteService- the base site service
-
getCommerceAddToCartStrategy
protected de.hybris.platform.commerceservices.order.CommerceAddToCartStrategy getCommerceAddToCartStrategy()Gets commerce add to cart strategy.- Returns:
- the commerce add to cart strategy
-
setCommerceAddToCartStrategy
public void setCommerceAddToCartStrategy(de.hybris.platform.commerceservices.order.CommerceAddToCartStrategy commerceAddToCartStrategy) Sets commerce add to cart strategy.- Parameters:
commerceAddToCartStrategy- the commerce add to cart strategy
-
getMergeAction
Gets merge action.- Returns:
- the merge action
-
setMergeAction
Sets merge action.- Parameters:
mergeAction- the merge action
-