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
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields inherited from class de.hybris.platform.commerceservices.order.impl.AbstractCommerceCartStrategy

    DEFAULT_FORCE_IN_STOCK_MAX_QUANTITY, forceInStockMaxQuantity
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    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.BaseSiteService
    Gets base site service.
    protected de.hybris.platform.commerceservices.order.CommerceAddToCartStrategy
    Gets commerce add to cart strategy.
    protected de.hybris.platform.commerceservices.order.CommerceCartService
    Gets commerce cart service.
    Gets merge action.
    protected de.hybris.platform.servicelayer.user.UserService
    Gets user service.
    void
    mergeCarts(CartModel fromCart, CartModel toCart, List<CommerceCartModification> modifications)
     
    protected void
    Merge modification to list.
    protected String
    mergeStatusCodes(String statusCode, String statusCode1)
    Merge status codes string.
    void
    setBaseSiteService(de.hybris.platform.site.BaseSiteService baseSiteService)
    Sets base site service.
    void
    setCommerceAddToCartStrategy(de.hybris.platform.commerceservices.order.CommerceAddToCartStrategy commerceAddToCartStrategy)
    Sets commerce add to cart strategy.
    void
    setCommerceCartService(de.hybris.platform.commerceservices.order.CommerceCartService commerceCartService)
    Sets commerce cart service.
    void
    Sets merge action.
    void
    setUserService(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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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:
      mergeCarts in interface de.hybris.platform.commerceservices.order.impl.CommerceCartMergingStrategy
      Throws:
      de.hybris.platform.commerceservices.order.CommerceCartMergingException
    • finaliseFromCart

      protected void finaliseFromCart(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.
      Parameters:
      fromCart - the from cart
    • mergeModificationToList

      protected void mergeModificationToList(CommerceCartModification modificationToAdd, List<CommerceCartModification> toModificationList)
      Merge modification to list.
      Parameters:
      modificationToAdd - the modification to add
      toModificationList - the to modification list
    • mergeStatusCodes

      protected String mergeStatusCodes(String statusCode, String statusCode1)
      Merge status codes string.
      Parameters:
      statusCode - the status code
      statusCode1 - 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

      protected ReplaceCartMergingStrategy.MergeAction getMergeAction()
      Gets merge action.
      Returns:
      the merge action
    • setMergeAction

      public void setMergeAction(ReplaceCartMergingStrategy.MergeAction mergeAction)
      Sets merge action.
      Parameters:
      mergeAction - the merge action