Class CartItemOfferUtils

java.lang.Object
com.broadleafcommerce.cartoperation.service.util.offer.CartItemOfferUtils

public class CartItemOfferUtils extends Object
Utility class to aid in processing CartItems regarding offers.
Author:
Sunny Yu
  • Constructor Summary

    Constructors
    Constructor
    Description
    CartItemOfferUtils(com.fasterxml.jackson.databind.ObjectMapper mapper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.broadleafcommerce.order.common.domain.Adjustment
    buildFreeGiftAdjustment(com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem freeGiftItem)
    Builds an Adjustment based on the supplied free gift and cart item.
    com.broadleafcommerce.order.common.domain.Adjustment
    buildFreeGiftAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment)
    Builds an Adjustment based on the given Adjustment.
    com.broadleafcommerce.order.common.domain.OfferItemDetail
    buildOfferItemDetails(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferItemDetail offerItemDetail)
    Builds an OfferItemDetail from the given OfferItemDetail.
    protected com.broadleafcommerce.order.common.domain.Adjustment
    Converts the given Object to an Adjustment.
    com.broadleafcommerce.order.common.domain.Adjustment
    getFreeGiftAdjustment(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Gets the temporarily stored Adjustment for the free gift item.
    javax.money.MonetaryAmount
    getGiftAdjustmentAmount(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Return the adjustment amount of a gift item.
    javax.money.MonetaryAmount
    getGiftFee(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    protected <T> T
    getInternalAttribute(com.broadleafcommerce.cart.client.domain.CartItem cartItem, String key)
     
    protected <T> T
    getInternalAttribute(com.broadleafcommerce.cart.client.domain.CartItem cartItem, String key, Class<T> type)
     
    protected com.fasterxml.jackson.databind.ObjectMapper
     
    getOriginOfferId(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Gets the id of the offer that this CartItem was a target of.
     
    List<com.broadleafcommerce.order.common.domain.OfferItemDetail>
    getQualifierCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Gets the offer qualifier OfferItemDetails that the given CartItem was a target of.
    getQualifierCartItemIds(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    The ids of the offer qualifier CartItems that the given CartItem was added from.
    protected com.broadleafcommerce.common.extension.TypeFactory
     
    boolean
    isFreeGiftItem(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Identifies if the given CartItem is a free gift item.
    void
    removeIsFreeGiftItemFlag(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Removes the CartItemAttributeConstants.Internal.IS_FREE_GIFT_ITEM attribute from the given CartItem.
    void
     
    void
    setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CartItemOfferUtils

      public CartItemOfferUtils(com.fasterxml.jackson.databind.ObjectMapper mapper)
  • Method Details

    • isFreeGiftItem

      public boolean isFreeGiftItem(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Identifies if the given CartItem is a free gift item.
      Parameters:
      cartItem - CartItem to check against
      Returns:
      true if the given CartItem is a free gift item, otherwise false
    • removeIsFreeGiftItemFlag

      public void removeIsFreeGiftItemFlag(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Removes the CartItemAttributeConstants.Internal.IS_FREE_GIFT_ITEM attribute from the given CartItem.
      Parameters:
      cartItem - CartItem to remove the CartItemAttributeConstants.Internal.IS_FREE_GIFT_ITEM from
    • getFreeGiftAdjustment

      public com.broadleafcommerce.order.common.domain.Adjustment getFreeGiftAdjustment(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Gets the temporarily stored Adjustment for the free gift item.
      See Also:
    • getGiftAdjustmentAmount

      @Nullable public javax.money.MonetaryAmount getGiftAdjustmentAmount(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Return the adjustment amount of a gift item. This is the unit price of the item minus the gift fee. Quantity is not considered in this calculation. If no gift fee is present, this method will return null.
      Returns:
      the gift adjustment amount.
      See Also:
    • getGiftFee

      @Nullable public javax.money.MonetaryAmount getGiftFee(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • getQualifierCartItemIds

      public List<String> getQualifierCartItemIds(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      The ids of the offer qualifier CartItems that the given CartItem was added from.
      Parameters:
      cartItem - CartItem to get the offer qualifier cart item ids from
      Returns:
      The ids of the offer qualifier CartItems that the given CartItem was added from
    • getQualifierCartItemDetails

      public List<com.broadleafcommerce.order.common.domain.OfferItemDetail> getQualifierCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Gets the offer qualifier OfferItemDetails that the given CartItem was a target of.
      Parameters:
      cartItem - the CartItem to get the offer qualifier OfferItemDetails from
      Returns:
      the offer qualifier OfferItemDetails that the given CartItem was a target of
    • convertAdjustment

      protected com.broadleafcommerce.order.common.domain.Adjustment convertAdjustment(Object adjustment)
      Converts the given Object to an Adjustment.
      Parameters:
      adjustment - the Object to convert from
      Returns:
      an Adjustment converted from Object
    • getOriginOfferId

      public String getOriginOfferId(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Gets the id of the offer that this CartItem was a target of. In other words, this id identifies which offer this CartItem was added from.
      Parameters:
      cartItem - CartItem to get the target offer id from
      Returns:
      the id of the offer that this CartItem was a target of
      See Also:
    • buildFreeGiftAdjustment

      public com.broadleafcommerce.order.common.domain.Adjustment buildFreeGiftAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment)
      Builds an Adjustment based on the given Adjustment.
      Parameters:
      offerAdjustment - the Adjustment to build it from
      Returns:
      an Adjustment based on the given Adjustment
    • buildFreeGiftAdjustment

      public com.broadleafcommerce.order.common.domain.Adjustment buildFreeGiftAdjustment(com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem freeGiftItem)
      Builds an Adjustment based on the supplied free gift and cart item.
      Parameters:
      cartItem - The cart item representing the gift.
      freeGiftItem - The free gift item.
      Returns:
      an Adjustment for the given free gift item
    • buildOfferItemDetails

      public com.broadleafcommerce.order.common.domain.OfferItemDetail buildOfferItemDetails(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferItemDetail offerItemDetail)
      Builds an OfferItemDetail from the given OfferItemDetail.
      Parameters:
      offerItemDetail - the OfferItemDetail to build the OfferItemDetail from
      Returns:
      an OfferItemDetail from the given OfferItemDetail
    • getInternalAttribute

      protected <T> T getInternalAttribute(com.broadleafcommerce.cart.client.domain.CartItem cartItem, String key)
    • getInternalAttribute

      protected <T> T getInternalAttribute(com.broadleafcommerce.cart.client.domain.CartItem cartItem, String key, Class<T> type)
    • getMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getMapper()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • setTypeFactory

      @Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
    • getPromotionProperties

      protected CartOpsPromotionProperties getPromotionProperties()
    • setPromotionProperties

      @Autowired public void setPromotionProperties(CartOpsPromotionProperties promotionProperties)