Class ExternalOfferProvider
- All Implemented Interfaces:
OfferProvider
- Author:
- Chad Harchar (charchar)
-
Field Summary
Fields inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionExternalOfferProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalOfferProperties properties, UserTargetGenerationService userTargetGenerationService, CartTotalsCalculator cartTotalsCalculator) -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyOffers(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean runOrderAndItemOffers, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles requests against the Offer Engine to retrieve and apply discounts for aCartand its contents.voidapplyOffers(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles requests against the Offer Engine to retrieve and apply discounts for aCartand its contents.protected com.broadleafcommerce.order.common.domain.AdjustmentbuildAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef myItemOffer, com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment) protected com.broadleafcommerce.order.common.domain.AdjustmentbuildItemAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment, boolean isForFulfillment) Builds anAdjustmentbased on the given parameters for aCartItemorFulfillmentItem.protected com.broadleafcommerce.order.common.domain.ItemProrationDetailbuildItemProrationDetail(com.broadleafcommerce.promotion.offer.client.web.context.info.ItemProrationDetail clientDetail) Builds anItemProrationDetailbased on the givenItemProrationDetail.protected 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.OfferRefbuildOfferRef(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef clientOfferRef) protected com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>>buildOrderDto(com.broadleafcommerce.cart.client.domain.Cart cart, boolean runOrderAndItemOffers, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.order.common.domain.ProratedOfferAdjustmentbuildProratedOrderAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment clientAdjustment) Builds anProratedOfferAdjustmentbased on the givenProratedOfferAdjustment.protected com.broadleafcommerce.order.common.domain.VoucherbuildVoucher(com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher voucher) Builds aVoucherfrom the givenVoucher.protected com.broadleafcommerce.promotion.offer.client.web.context.DestinationconvertAddressToDestination(@NonNull com.broadleafcommerce.order.common.domain.Address address) Converts anAddressto aDestination.protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContextCreate aCustomerContextand add customer and customer segments.protected List<com.broadleafcommerce.order.common.domain.Adjustment>getAdjustments(List<com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment> adjustments) protected List<com.broadleafcommerce.order.common.domain.Adjustment>getCartItemAdjustmentsToAdd(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> itemResponseDetail) Gets a list ofAdjustmentsfor aCartItembased on the givenItemResponseDetail.protected CartOperationServicePropertiesprotected CartOperationServiceOfferUtilsprotected CartTotalsCalculatorprotected org.springframework.core.ParameterizedTypeReference<Map<String,com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo>> getCodeUsabilityType(@NonNull String code, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines the usability type of the promocodein the context of the givencart.protected List<com.broadleafcommerce.order.common.domain.Adjustment>getFulfillmentItemAdjustmentsToAdd(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> itemResponseDetail) Gets a list ofAdjustmentsfor aFulfillmentItembased on the givenItemResponseDetail.protected ObjectgetProductType(com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected List<com.broadleafcommerce.order.common.domain.ProratedOfferAdjustment>getProratedOrderAdjustmentsToAdd(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> orderItemResponse) Gets a list ofProratedOfferAdjustmentsfor aCartItembased on the givenItemResponse.protected Stringprotected Optional<javax.money.MonetaryAmount>getStandardPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected UserTargetGenerationServiceprotected List<com.broadleafcommerce.order.common.domain.Voucher>getVouchers(List<com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher> vouchers) protected booleanhasSalePrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected booleanhasStandardPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected booleanisFulfillmentItemForBundle(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, Map<String, com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItemIdMap) protected com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDtopopulateBundleFulfillmentLineItemDto(Map<String, com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItemIdMap, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem) protected com.broadleafcommerce.promotion.offer.client.web.context.CodespopulateCodes(com.broadleafcommerce.cart.client.domain.Cart cart) Deprecated.protected voidpopulateDependentLineItemDto(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>populateFulfillmentGroupDto(Map<String, com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItemIdMap, com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) protected List<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>>populateFulfillmentGroupDtos(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.cart.client.domain.Cart cart) protected com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDtopopulateFulfillmentLineItemDto(Map<String, com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItemIdMap, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem) protected com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDtopopulateLineItemDto(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Returns a populatedOrderLineItemDtofrom givenCartItem.protected voidpopulateLineItemDto(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.cart.client.domain.CartItem cartItem) Deprecated.in favor ofpopulateLineItemDto(CartItem)for simpler client extensionprotected List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto>populateLineItems(com.broadleafcommerce.cart.client.domain.Cart cart) populateOfferCodeAttributes(com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto offerCode, com.broadleafcommerce.cart.client.domain.Cart cart) Hook point to add additonal attributes to the offer codes before sending to the offer service.protected List<com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto>populateOfferCodes(com.broadleafcommerce.cart.client.domain.Cart cart) protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto>
voidprocessFreeGiftOffers(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T> orderResponse) voidsetCartOpProperties(CartOperationServiceProperties cartOpProperties) voidsetCartOpsServiceOfferUtils(CartOperationServiceOfferUtils cartOpsServiceOfferUtils) protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto>
voidupdateCartAdjustments(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T> orderResponse, boolean didRunOrderAndItemOffers) Updates the cart, items, and fulfillment groups and items with the discount adjustments contained in the response from the offer engine.protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto>
voidupdateCartForFulfillmentOffers(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T> orderResponse) Updates fulfillment groups and items with adjustments after the offer engine has processed the order.protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto>
voidupdateCartForOrderAndOrderItemOffers(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T> orderResponse) Updates order and order items with adjustments after the offer engine has processed the order.protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto>
voidupdateCartItem(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<T> orderItemResponse, com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto>
voidupdateFulfillmentGroup(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.promotion.offer.client.web.context.discounts.FulfillmentGroupResponse<T> fgResponse, com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto>
voidupdateFulfillmentItem(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<T> itemResponse, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem) com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResultvalidateOfferAndOfferCodeUsages(com.broadleafcommerce.cart.client.domain.Cart cart, List<String> offerCodes, List<String> offerIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve validation information regarding the cart's usage of the provided offers and offer codes to determine if the usage is still valid.Methods inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
buildNotFoundException, executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, pageableToParams, uriVars
-
Constructor Details
-
ExternalOfferProvider
public ExternalOfferProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalOfferProperties properties, UserTargetGenerationService userTargetGenerationService, CartTotalsCalculator cartTotalsCalculator)
-
-
Method Details
-
applyOffers
public void applyOffers(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferProviderHandles requests against the Offer Engine to retrieve and apply discounts for aCartand its contents. This method should apply all kinds of offers applicable to the contents including all order, order item, fulfillment, and fulfillment item offers.To control whether order and order item offers are applied use
OfferProvider.applyOffers(Cart, boolean, ContextInfo)and set `runOrderAndItemOffers` as desired. Set it tofalseif you only want to run fulfillment and fulfillment item offers. By default, fulfillment pricing occurs after order and order items have been priced and their offers applied since fulfillment pricing and promotions can depend on the price of the merchandise being fulfilled.- Specified by:
applyOffersin interfaceOfferProvider- Parameters:
cart- TheCartwhose contents to send to the offer engine for evaluationcontextInfo- Additional sandbox and tenancy info
-
applyOffers
public void applyOffers(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean runOrderAndItemOffers, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferProviderHandles requests against the Offer Engine to retrieve and apply discounts for aCartand its contents. Allows specifying whether order and order item offers will be applied in the calculation. SetrunOrderAndItemOfferstofalseif you only want to run fulfillment and fulfillment item offers.By default, fulfillment pricing occurs after order and order items have been priced and their offers applied since fulfillment pricing and promotions can depend on the price of the merchandise being fulfilled. Thus, when fulfillment offers are processed, order and order item offers should not also be reprocessed or the results can be incorrect—this also makes the request run faster since only fulfillment will be considered.
- Specified by:
applyOffersin interfaceOfferProvider- Parameters:
cart- TheCartwhose contents to send to the offer engine for evaluationrunOrderAndItemOffers- Whether to have the Offer Engine run order and order item level offers. Set this tofalseif you only want to run fulfillment and fulfillment item offers. By default, fulfillment pricing occurs after order and order items have been priced and their offers applied since fulfillment pricing and promotions can depend on the price of the merchandise being fulfilled.contextInfo- Additional sandbox and tenancy info
-
getCodeUsabilityType
public String getCodeUsabilityType(@NonNull @NonNull String code, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferProviderDetermines the usability type of the promocodein the context of the givencart. Possible values are defined inCodeUsabilityTypeand include whether the code is usable, cannot be used because it has reached its max uses limit, or cannot be used because it does not match any offers (may be a campaign code or some other type in this case).- Specified by:
getCodeUsabilityTypein interfaceOfferProvider- Parameters:
code- The promo code to apply tocartcart- TheCartthat promocodeis to be applied tocontextInfo- Additional sandbox and tenancy info- Returns:
- The usability type
- See Also:
-
CodeUsabilityType
-
validateOfferAndOfferCodeUsages
public com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult validateOfferAndOfferCodeUsages(com.broadleafcommerce.cart.client.domain.Cart cart, List<String> offerCodes, List<String> offerIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferProviderRetrieve validation information regarding the cart's usage of the provided offers and offer codes to determine if the usage is still valid.- Specified by:
validateOfferAndOfferCodeUsagesin interfaceOfferProvider- Parameters:
cart- The cart against which to validate offer and code uses.offerCodes- The codes to check for validity.offerIds- The offer ids to check for validity.contextInfo- Context information around sandbox and multitenant state.- Returns:
- A validation result that holds information about which offer & offer code usages are invalid and why
-
buildOrderDto
protected com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> buildOrderDto(com.broadleafcommerce.cart.client.domain.Cart cart, boolean runOrderAndItemOffers, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
populateLineItems
protected List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> populateLineItems(com.broadleafcommerce.cart.client.domain.Cart cart) -
populateFulfillmentGroupDtos
protected List<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> populateFulfillmentGroupDtos(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.cart.client.domain.Cart cart) -
populateCodes
@Deprecated protected com.broadleafcommerce.promotion.offer.client.web.context.Codes populateCodes(com.broadleafcommerce.cart.client.domain.Cart cart) Deprecated.usepopulateOfferCodes(Cart)instead -
populateOfferCodes
protected List<com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto> populateOfferCodes(com.broadleafcommerce.cart.client.domain.Cart cart) -
populateOfferCodeAttributes
protected Map<String,Object> populateOfferCodeAttributes(com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto offerCode, com.broadleafcommerce.cart.client.domain.Cart cart) Hook point to add additonal attributes to the offer codes before sending to the offer service.- Parameters:
offerCode- The offer code DTOcart- the current cart- Returns:
- the list of attributes to add to the offer code
-
getProductType
@Nullable protected Object getProductType(com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
populateDependentLineItemDto
protected void populateDependentLineItemDto(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
populateLineItemDto
@Deprecated protected void populateLineItemDto(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.cart.client.domain.CartItem cartItem) Deprecated.in favor ofpopulateLineItemDto(CartItem)for simpler client extensionPopulates anOrderLineItemDtofrom givenCartItemand adds it to the given list ofOrderLineItemDtos.- Parameters:
lineItems- the list ofOrderLineItemDtosto add the populatedOrderLineItemDtotocartItem- theCartItemto populate anOrderLineItemDtofrom
-
populateLineItemDto
protected com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto populateLineItemDto(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Returns a populatedOrderLineItemDtofrom givenCartItem.- Parameters:
cartItem- theCartItemto populate anOrderLineItemDtofrom- Returns:
- populated
OrderLineItemDtofrom givenCartItem
-
populateFulfillmentGroupDto
protected com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto> populateFulfillmentGroupDto(Map<String, com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItemIdMap, com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) -
isFulfillmentItemForBundle
-
convertAddressToDestination
protected com.broadleafcommerce.promotion.offer.client.web.context.Destination convertAddressToDestination(@NonNull @NonNull com.broadleafcommerce.order.common.domain.Address address) Converts anAddressto aDestination.- Parameters:
address-Addressto be converted- Returns:
- the
Destinationfrom theAddress.
-
populateBundleFulfillmentLineItemDto
protected com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto populateBundleFulfillmentLineItemDto(Map<String, com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItemIdMap, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem) -
populateFulfillmentLineItemDto
-
hasStandardPrice
protected boolean hasStandardPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
hasSalePrice
protected boolean hasSalePrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
getStandardPrice
protected Optional<javax.money.MonetaryAmount> getStandardPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
updateCartAdjustments
protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> void updateCartAdjustments(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T> orderResponse, boolean didRunOrderAndItemOffers) Updates the cart, items, and fulfillment groups and items with the discount adjustments contained in the response from the offer engine. This will take into account whether order and order item adjustments were calculated or fulfillment and fulfillment item ones in order to avoid overwriting the wrong ones.Fulfillment offers cannot be applied until after regular fulfillment pricing occurs, which cannot be calculated until after non-fulfillment subtotals and adjustments are calculated since fulfillment pricing is usually based on merchandise totals. Therefore, which part of the flow we're in needs to be determined since not all adjustments are calculated at the same time and we do not want to overwrite the previously calculated adjustments with null or 0 values. This determination is done using the
didRunOrderAndItemOffersflag.- Type Parameters:
T- The specific type ofProratedItemOfferAdjustmentDtobeing used in theOrderResponse- Parameters:
cart- The cart containing the fulfillment groups being discountedorderResponse- The response from the offer engine after processing the cart to determine applicable discountsdidRunOrderAndItemOffers- Indicates whether fulfillment or merchandise (order/item) adjustments have just been calculated
-
updateCartForFulfillmentOffers
protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> void updateCartForFulfillmentOffers(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T> orderResponse) Updates fulfillment groups and items with adjustments after the offer engine has processed the order. This is separated fromupdateCartForOrderAndOrderItemOffers(com.broadleafcommerce.cart.client.domain.Cart, com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T>)since fulfillment offers cannot be applied until after regular fulfillment pricing occurs, which cannot be calculated until after non-fulfillment subtotals and adjustments are calculated since fulfillment pricing is usually based on merchandise totals.- Type Parameters:
T- The specific type ofProratedItemOfferAdjustmentDtobeing used in theOrderResponse- Parameters:
cart- The cart containing the fulfillment groups being discountedorderResponse- The response from the offer engine after processing the cart to determine applicable discounts
-
updateCartForOrderAndOrderItemOffers
protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> void updateCartForOrderAndOrderItemOffers(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T> orderResponse) Updates order and order items with adjustments after the offer engine has processed the order. This is separated fromupdateCartForFulfillmentOffers(com.broadleafcommerce.cart.client.domain.Cart, com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T>)since fulfillment offers cannot be applied until after regular fulfillment pricing occurs, which cannot be calculated until after non-fulfillment subtotals and adjustments are calculated since fulfillment pricing is usually based on merchandise totals.- Type Parameters:
T- The specific type ofProratedItemOfferAdjustmentDtobeing used in theOrderResponse- Parameters:
cart- The cart and its items being discountedorderResponse- The response from the offer engine after processing the cart to determine applicable discounts
-
processFreeGiftOffers
protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> void processFreeGiftOffers(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T> orderResponse) -
updateFulfillmentGroup
protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> void updateFulfillmentGroup(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.promotion.offer.client.web.context.discounts.FulfillmentGroupResponse<T> fgResponse, com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) -
getAdjustments
-
getVouchers
-
buildVoucher
protected com.broadleafcommerce.order.common.domain.Voucher buildVoucher(com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher voucher) Builds aVoucherfrom the givenVoucher.- Parameters:
voucher- theVoucherto build theVoucherfrom- Returns:
- a
Voucherfrom the givenVoucher
-
updateFulfillmentItem
protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> void updateFulfillmentItem(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<T> itemResponse, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem) -
updateCartItem
protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> void updateCartItem(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<T> orderItemResponse, com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
getCartItemAdjustmentsToAdd
protected List<com.broadleafcommerce.order.common.domain.Adjustment> getCartItemAdjustmentsToAdd(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> itemResponseDetail) Gets a list ofAdjustmentsfor aCartItembased on the givenItemResponseDetail.- Parameters:
itemResponseDetail- theItemResponseDetailto build theAdjustmentsfrom- Returns:
- a list of
Adjustmentsfor aCartItembased on the givenItemResponseDetail
-
getFulfillmentItemAdjustmentsToAdd
protected List<com.broadleafcommerce.order.common.domain.Adjustment> getFulfillmentItemAdjustmentsToAdd(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> itemResponseDetail) Gets a list ofAdjustmentsfor aFulfillmentItembased on the givenItemResponseDetail.- Parameters:
itemResponseDetail- theItemResponseDetailto build theAdjustmentsfrom- Returns:
- a list of
Adjustmentsfor aFulfillmentItembased on the givenItemResponseDetail
-
buildOfferRef
protected com.broadleafcommerce.order.common.domain.OfferRef buildOfferRef(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef clientOfferRef) -
buildAdjustment
protected com.broadleafcommerce.order.common.domain.Adjustment buildAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef myItemOffer, com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment) -
buildItemAdjustment
protected com.broadleafcommerce.order.common.domain.Adjustment buildItemAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment, boolean isForFulfillment) Builds anAdjustmentbased on the given parameters for aCartItemorFulfillmentItem.- Parameters:
offerAdjustment- theAdjustmentto build it fromisForFulfillment- whether the adjustment is for fulfillment item- Returns:
- an
Adjustmentbased on the given parameters for aCartItemorFulfillmentItem
-
buildOfferItemDetails
protected 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
-
getProratedOrderAdjustmentsToAdd
protected List<com.broadleafcommerce.order.common.domain.ProratedOfferAdjustment> getProratedOrderAdjustmentsToAdd(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> orderItemResponse) Gets a list ofProratedOfferAdjustmentsfor aCartItembased on the givenItemResponse.- Parameters:
orderItemResponse- theItemResponseto build theProratedOfferAdjustmentsfrom- Returns:
- a list of
ProratedOfferAdjustmentsfor aCartItembased on the givenItemResponse
-
buildProratedOrderAdjustment
protected com.broadleafcommerce.order.common.domain.ProratedOfferAdjustment buildProratedOrderAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment clientAdjustment) Builds anProratedOfferAdjustmentbased on the givenProratedOfferAdjustment.- Parameters:
clientAdjustment- theProratedOfferAdjustmentto build it from- Returns:
- an
ProratedOfferAdjustmentbased on the givenProratedOfferAdjustment
-
buildItemProrationDetail
protected com.broadleafcommerce.order.common.domain.ItemProrationDetail buildItemProrationDetail(com.broadleafcommerce.promotion.offer.client.web.context.info.ItemProrationDetail clientDetail) Builds anItemProrationDetailbased on the givenItemProrationDetail.- Parameters:
clientDetail- theItemProrationDetailto build it from- Returns:
- an
ItemProrationDetailbased on the givenItemProrationDetail
-
createCustomerContext
protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext createCustomerContext()Create aCustomerContextand add customer and customer segments. Uses the current authentication token to determine principal and details.- Returns:
- The created
CustomerContext
-
getCodeUsabilityInfoMap
-
getServiceClient
-
getUserTargetGenerationService
-
getCartTotalsCalculator
-
getCartOpsServiceOfferUtils
-
setCartOpsServiceOfferUtils
@Autowired public void setCartOpsServiceOfferUtils(CartOperationServiceOfferUtils cartOpsServiceOfferUtils) -
getCartOpProperties
-
setCartOpProperties
-
populateOfferCodes(Cart)instead