public class CartItemOfferUtils extends Object
CartItems
regarding offers.Constructor and Description |
---|
CartItemOfferUtils(com.fasterxml.jackson.databind.ObjectMapper mapper) |
Modifier and Type | Method and Description |
---|---|
void |
addTargetCartItemDetail(com.broadleafcommerce.cart.client.domain.CartItem cartItem,
com.broadleafcommerce.order.common.domain.OfferItemDetail targetItemDetail)
Adds the offer target
OfferItemDetail to the given CartItem . |
protected List<com.broadleafcommerce.order.common.domain.OfferItemDetail> |
convertItemDetails(Object details)
|
protected Optional<com.broadleafcommerce.order.common.domain.OfferItemDetail> |
findMatchingDetail(List<com.broadleafcommerce.order.common.domain.OfferItemDetail> offerItemDetails,
com.broadleafcommerce.order.common.domain.OfferItemDetail offerItemDetail)
Finds the matching
OfferItemDetail based on OfferItemDetail.getItemId() and
OfferItemDetail.getOfferId() from the given list of OfferItemDetails . |
protected com.fasterxml.jackson.databind.ObjectMapper |
getMapper() |
String |
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. |
List<String> |
getQualifierCartItemIds(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
The
ids of the offer qualifier CartItems that the
given CartItem was added from. |
List<com.broadleafcommerce.order.common.domain.OfferItemDetail> |
getTargetCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Gets the offer target
OfferItemDetails that the given
CartItem was a qualifier of. |
List<String> |
getTargetCartItemIds(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
The
ids of the offer target CartItems that the
given CartItem was a qualifier of. |
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.getInternalAttributes() . |
void |
removeQualifierAndTargetDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem,
String itemIdToRemove)
Remove all qualifier and target
OfferItemDetails that match the given
OfferItemDetail.getItemId() . |
void |
setQualifierCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem,
List<com.broadleafcommerce.order.common.domain.OfferItemDetail> qualifierItemDetails)
Sets the offer qualifier
OfferItemDetails that the given
CartItem was a target of. |
void |
setTargetCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem,
List<com.broadleafcommerce.order.common.domain.OfferItemDetail> targetItemDetails)
Sets the offer target
OfferItemDetails that the given
CartItem was a qualifier of. |
public CartItemOfferUtils(com.fasterxml.jackson.databind.ObjectMapper mapper)
public boolean isFreeGiftItem(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
CartItem
is a free gift item.cartItem
- CartItem
to check againstCartItem
is a free gift item, otherwise falsepublic void removeIsFreeGiftItemFlag(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
CartItemAttributeConstants.Internal.IS_FREE_GIFT_ITEM
attribute from the given
CartItem.getInternalAttributes()
.cartItem
- CartItem
to remove the CartItemAttributeConstants.Internal.IS_FREE_GIFT_ITEM
frompublic List<String> getQualifierCartItemIds(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
ids
of the offer qualifier CartItems
that the
given CartItem
was added from.cartItem
- CartItem
to get the offer qualifier cart item
ids
fromids
of the offer qualifier CartItems
that the given CartItem
was added fromCartItemAttributeConstants.Internal.QUALIFIER_CART_ITEM_DETAILS
public List<com.broadleafcommerce.order.common.domain.OfferItemDetail> getQualifierCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
OfferItemDetails
that the given
CartItem
was a target of.cartItem
- the CartItem
to get the offer qualifier OfferItemDetails
fromOfferItemDetails
that the given
CartItem
was a target ofCartItemAttributeConstants.Internal.QUALIFIER_CART_ITEM_DETAILS
public void setQualifierCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.order.common.domain.OfferItemDetail> qualifierItemDetails)
OfferItemDetails
that the given
CartItem
was a target of.cartItem
- CartItem
to set the offer qualifier OfferItemDetails
forqualifierItemDetails
- the offer qualifier OfferItemDetails
CartItemAttributeConstants.Internal.QUALIFIER_CART_ITEM_DETAILS
public List<String> getTargetCartItemIds(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
ids
of the offer target CartItems
that the
given CartItem
was a qualifier of.cartItem
- CartItem
to get the offer target cart item
ids
fromids
of the offer target CartItems
that
the given CartItem
was a qualifier ofCartItemAttributeConstants.Internal.TARGET_CART_ITEM_DETAILS
public List<com.broadleafcommerce.order.common.domain.OfferItemDetail> getTargetCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
OfferItemDetails
that the given
CartItem
was a qualifier of.cartItem
- the CartItem
to get the offer target OfferItemDetails
fromOfferItemDetails
that the given
CartItem
was a qualifier ofCartItemAttributeConstants.Internal.TARGET_CART_ITEM_DETAILS
public void addTargetCartItemDetail(com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.order.common.domain.OfferItemDetail targetItemDetail)
OfferItemDetail
to the given CartItem
.cartItem
- the CartItem
to add the offer target OfferItemDetail
toprotected Optional<com.broadleafcommerce.order.common.domain.OfferItemDetail> findMatchingDetail(List<com.broadleafcommerce.order.common.domain.OfferItemDetail> offerItemDetails, com.broadleafcommerce.order.common.domain.OfferItemDetail offerItemDetail)
OfferItemDetail
based on OfferItemDetail.getItemId()
and
OfferItemDetail.getOfferId()
from the given list of OfferItemDetails
.offerItemDetails
- the list of OfferItemDetails
to look againstofferItemDetail
- the OfferItemDetail
to look forOfferItemDetail
based on OfferItemDetail.getItemId()
and
OfferItemDetail.getOfferId()
from the given list of OfferItemDetails
public void setTargetCartItemDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.order.common.domain.OfferItemDetail> targetItemDetails)
OfferItemDetails
that the given
CartItem
was a qualifier of.cartItem
- CartItem
to set the offer target OfferItemDetails
fortargetItemDetails
- the offer target OfferItemDetails
CartItemAttributeConstants.Internal.TARGET_CART_ITEM_DETAILS
protected List<com.broadleafcommerce.order.common.domain.OfferItemDetail> convertItemDetails(Object details)
public void removeQualifierAndTargetDetails(com.broadleafcommerce.cart.client.domain.CartItem cartItem, String itemIdToRemove)
OfferItemDetails
that match the given
OfferItemDetail.getItemId()
.cartItem
- the CartItem
to remove the qualifier and target
OfferItemDetails
fromitemIdToRemove
- the item id of the OfferItemDetails
to removepublic String getOriginOfferId(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
CartItem
was a target of. In other words, this id
identifies which offer this CartItem
was added from.cartItem
- CartItem
to get the target offer id fromCartItem
was a target ofCartItemAttributeConstants.Internal.ORIGIN_OFFER_ID
protected com.fasterxml.jackson.databind.ObjectMapper getMapper()
Copyright © 2021. All rights reserved.