Class CartOfferUtils


  • public class CartOfferUtils
    extends Object
    Utility class to aid in retrieving offer information from Cart.
    Author:
    Sunny Yu
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCartItemQualifiedOfferIdsToIgnoreList​(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems)
      Retrieves the offer ids that the given CartItems that are qualifiers of and add them to the given Cart's offer ignore list.
      List<com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem> getFreeGiftItemsFromOffers​(com.broadleafcommerce.cart.client.domain.Cart cart)
      Retrieves the FreeGiftItems applicable to the given Cart.
      List<String> getOfferIdsToIgnore​(com.broadleafcommerce.cart.client.domain.Cart cart)
      Retrieves the offer ids to ignore and not apply to the given Cart.
      boolean offerShouldBeIgnored​(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offerRef)
      Determines if the given OfferRef should be ignored for the given Cart.
      void storeFreeGiftItems​(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem> freeGiftItems)
      Adds the given FreeGiftItems to Cart.getInternalAttributes() for later processing.
    • Constructor Detail

    • Method Detail

      • storeFreeGiftItems

        public void storeFreeGiftItems​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                       List<com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem> freeGiftItems)
        Adds the given FreeGiftItems to Cart.getInternalAttributes() for later processing.
        Parameters:
        cart - the Cart to add the FreeGiftItems for
        freeGiftItems - the FreeGiftItems to add to Cart.getInternalAttributes()
        See Also:
        CartAttributeConstants.Internal.FREE_GIFT_OFFER_ITEMS
      • getFreeGiftItemsFromOffers

        public List<com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem> getFreeGiftItemsFromOffers​(com.broadleafcommerce.cart.client.domain.Cart cart)
        Retrieves the FreeGiftItems applicable to the given Cart.
        Parameters:
        cart - the Cart to retrieve the applicable FreeGiftItems from
        Returns:
        the FreeGiftItems applicable to the given Cart
        See Also:
        CartAttributeConstants.Internal.FREE_GIFT_OFFER_ITEMS
      • getOfferIdsToIgnore

        public List<String> getOfferIdsToIgnore​(com.broadleafcommerce.cart.client.domain.Cart cart)
        Retrieves the offer ids to ignore and not apply to the given Cart.
        Parameters:
        cart - the Cart to retrieve the ignored offer ids from
        Returns:
        the offer ids to ignore and not apply to the given Cart
        See Also:
        CartAttributeConstants.Internal.OFFER_IDS_TO_IGNORE
      • offerShouldBeIgnored

        public boolean offerShouldBeIgnored​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                            com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offerRef)
        Determines if the given OfferRef should be ignored for the given Cart.
        Parameters:
        cart - the Cart to check against
        offerRef - the OfferRef to check against
        Returns:
        true if given OfferRef should be ignored, otherwise false
        See Also:
        CartAttributeConstants.Internal.OFFER_IDS_TO_IGNORE
      • addCartItemQualifiedOfferIdsToIgnoreList

        public void addCartItemQualifiedOfferIdsToIgnoreList​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                                             List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems)
        Retrieves the offer ids that the given CartItems that are qualifiers of and add them to the given Cart's offer ignore list.

        This is typically used when removing automatically added CartItems from offers, but no longer want to apply those offers again.

        Parameters:
        cart - the Cart to add the offer ids to ignore for
        cartItems - the CartItems to retrieve their qualified offer ids for