Class CartItemOfferUtils
java.lang.Object
com.broadleafcommerce.cartoperation.service.util.offer.CartItemOfferUtils
Utility class to aid in processing
CartItems regarding offers.- Author:
- Sunny Yu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.broadleafcommerce.order.common.domain.AdjustmentbuildFreeGiftAdjustment(com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem freeGiftItem) Builds anAdjustmentbased on the supplied free gift and cart item.com.broadleafcommerce.order.common.domain.AdjustmentbuildFreeGiftAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment) Builds anAdjustmentbased on the givenAdjustment.com.broadleafcommerce.order.common.domain.OfferItemDetailbuildOfferItemDetails(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferItemDetail offerItemDetail) Builds anOfferItemDetailfrom the givenOfferItemDetail.protected com.broadleafcommerce.order.common.domain.AdjustmentconvertAdjustment(Object adjustment) Converts the givenObjectto anAdjustment.com.broadleafcommerce.order.common.domain.AdjustmentgetFreeGiftAdjustment(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Gets the temporarily storedAdjustmentfor the free gift item.javax.money.MonetaryAmountgetGiftAdjustmentAmount(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Return the adjustment amount of a gift item.javax.money.MonetaryAmountgetGiftFee(com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected <T> TgetInternalAttribute(com.broadleafcommerce.cart.client.domain.CartItem cartItem, String key) protected <T> TgetInternalAttribute(com.broadleafcommerce.cart.client.domain.CartItem cartItem, String key, Class<T> type) protected com.fasterxml.jackson.databind.ObjectMappergetOriginOfferId(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Gets the id of the offer that thisCartItemwas a target of.protected CartOpsPromotionPropertiesList<com.broadleafcommerce.order.common.domain.OfferItemDetail>getQualifierCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Gets the offer qualifierOfferItemDetailsthat the givenCartItemwas a target of.getQualifierCartItemIds(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Theidsof the offer qualifierCartItemsthat the givenCartItemwas added from.protected com.broadleafcommerce.common.extension.TypeFactorybooleanisFreeGiftItem(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Identifies if the givenCartItemis a free gift item.voidremoveIsFreeGiftItemFlag(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Removes theCartItemAttributeConstants.Internal.IS_FREE_GIFT_ITEMattribute from the givenCartItem.voidsetPromotionProperties(CartOpsPromotionProperties promotionProperties) voidsetTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
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 givenCartItemis a free gift item.- Parameters:
cartItem-CartItemto check against- Returns:
- true if the given
CartItemis a free gift item, otherwise false
-
removeIsFreeGiftItemFlag
public void removeIsFreeGiftItemFlag(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Removes theCartItemAttributeConstants.Internal.IS_FREE_GIFT_ITEMattribute from the givenCartItem.- Parameters:
cartItem-CartItemto remove theCartItemAttributeConstants.Internal.IS_FREE_GIFT_ITEMfrom
-
getFreeGiftAdjustment
public com.broadleafcommerce.order.common.domain.Adjustment getFreeGiftAdjustment(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Gets the temporarily storedAdjustmentfor the free gift item. -
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) Theidsof the offer qualifierCartItemsthat the givenCartItemwas added from.- Parameters:
cartItem-CartItemto get the offer qualifiercart item idsfrom- Returns:
- The
idsof the offer qualifierCartItemsthat the givenCartItemwas added from
-
getQualifierCartItemDetails
public List<com.broadleafcommerce.order.common.domain.OfferItemDetail> getQualifierCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Gets the offer qualifierOfferItemDetailsthat the givenCartItemwas a target of.- Parameters:
cartItem- theCartItemto get the offer qualifierOfferItemDetailsfrom- Returns:
- the offer qualifier
OfferItemDetailsthat the givenCartItemwas a target of
-
convertAdjustment
Converts the givenObjectto anAdjustment. -
getOriginOfferId
Gets the id of the offer that thisCartItemwas a target of. In other words, this id identifies which offer thisCartItemwas added from.- Parameters:
cartItem-CartItemto get the target offer id from- Returns:
- the id of the offer that this
CartItemwas 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 anAdjustmentbased on the givenAdjustment.- Parameters:
offerAdjustment- theAdjustmentto build it from- Returns:
- an
Adjustmentbased on the givenAdjustment
-
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 anAdjustmentbased on the supplied free gift and cart item.- Parameters:
cartItem- The cart item representing the gift.freeGiftItem- The free gift item.- Returns:
- an
Adjustmentfor 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 anOfferItemDetailfrom the givenOfferItemDetail.- Parameters:
offerItemDetail- theOfferItemDetailto build theOfferItemDetailfrom- Returns:
- an
OfferItemDetailfrom the givenOfferItemDetail
-
getInternalAttribute
protected <T> T getInternalAttribute(com.broadleafcommerce.cart.client.domain.CartItem cartItem, String key) -
getInternalAttribute
-
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
-
setPromotionProperties
-