Class MergeCartServiceImpl

java.lang.Object
org.broadleafcommerce.core.order.service.MergeCartServiceImpl
All Implemented Interfaces:
MergeCartService

@Service("blMergeCartService") public class MergeCartServiceImpl extends Object implements MergeCartService
The 2.0 implementation of merge cart service. Instead of merging items directly from one cart to another, we will convert the previous cart to a named order that the customer is able to interact with as they see fit.
Author:
Andre Azzolini (apazzolini)
  • Field Details

  • Constructor Details

    • MergeCartServiceImpl

      public MergeCartServiceImpl()
  • Method Details

    • mergeCart

      public MergeCartResponse mergeCart(org.broadleafcommerce.profile.core.domain.Customer customer, Order anonymousCart) throws PricingException, RemoveFromCartException
      Description copied from interface: MergeCartService
      Delegates to mergeCart(Customer, Order, boolean) with priceOrder set to true

      Merges the anonymous cart with the customer's current cart, taking into consideration the active status of the SKUs to merge. For example, if the customer had a SKU in their anonymous cart that is no longer active, it will not be merged into the new cart.

      Specified by:
      mergeCart in interface MergeCartService
      Parameters:
      customer - the customer whose cart is to be merged
      anonymousCart - the anonymous cart id
      Returns:
      the response containing the cart, any items added to the cart, and any items removed from the cart
      Throws:
      PricingException
      RemoveFromCartException
    • reconstructCart

      public ReconstructCartResponse reconstructCart(org.broadleafcommerce.profile.core.domain.Customer customer) throws PricingException, RemoveFromCartException
      Description copied from interface: MergeCartService
      Delegates to reconstructCart(Customer, boolean) with priceOrder set to true

      Reconstruct the cart using previous stored state taking into consideration sku activation

      Specified by:
      reconstructCart in interface MergeCartService
      Parameters:
      customer - the customer whose cart is to be reconstructed
      Returns:
      the response containing the cart and any items removed from the cart
      Throws:
      PricingException
      RemoveFromCartException
    • mergeCart

      public MergeCartResponse mergeCart(org.broadleafcommerce.profile.core.domain.Customer customer, Order anonymousCart, boolean priceOrder) throws PricingException, RemoveFromCartException
      Description copied from interface: MergeCartService
      Merges the anonymous cart with the customer's current cart, taking into consideration the active status of the SKUs to merge. For example, if the customer had a SKU in their anonymous cart that is no longer active, it will not be merged into the new cart.
      Specified by:
      mergeCart in interface MergeCartService
      Parameters:
      customer - the customer whose cart is to be merged
      anonymousCart - the anonymous cart id
      priceOrder - whether or not to price the order
      Returns:
      the response containing the cart, any items added to the cart, and any items removed from the cart
      Throws:
      PricingException
      RemoveFromCartException
    • reconstructCart

      public ReconstructCartResponse reconstructCart(org.broadleafcommerce.profile.core.domain.Customer customer, boolean priceOrder) throws PricingException, RemoveFromCartException
      Description copied from interface: MergeCartService
      Reconstruct the cart using previous stored state taking into consideration sku activation
      Specified by:
      reconstructCart in interface MergeCartService
      Parameters:
      customer - the customer whose cart is to be reconstructed
      Returns:
      the response containing the cart and any items removed from the cart
      Throws:
      RemoveFromCartException
      PricingException
    • setSavedCartAttributes

      protected void setSavedCartAttributes(Order cart)
    • setNewCartOwnership

      protected void setNewCartOwnership(Order cart, org.broadleafcommerce.profile.core.domain.Customer customer)
    • checkActive

      protected boolean checkActive(DiscreteOrderItem orderItem)
      Parameters:
      orderItem -
      Returns:
      whether or not the discrete order item's sku is active
    • checkInventory

      protected boolean checkInventory(DiscreteOrderItem orderItem)
      By default, Broadleaf does not provide an inventory check. This is set up as an extension point if your application needs it.
      Parameters:
      orderItem -
      Returns:
      whether or not the item is in stock
    • checkOtherValidity

      protected boolean checkOtherValidity(OrderItem orderItem)
      By default, Broadleaf does not provide additional validity checks. This is set up as an extension point if your application needs it.
      Parameters:
      orderItem -
      Returns:
      whether or not the orderItem is valid