java.lang.Object
com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.cartoperation.service.provider.external.ExternalOfferProvider
All Implemented Interfaces:
OfferProvider

public class ExternalOfferProvider extends AbstractExternalProvider implements OfferProvider
Author:
Chad Harchar (charchar)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
     
    protected static final String
     

    Fields inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider

    ENTITY_NOT_FOUND
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 Summary

    Modifier and Type
    Method
    Description
    protected void
    addDynamicOffersMap(com.broadleafcommerce.promotion.offer.client.web.context.OrderDto orderDto, com.broadleafcommerce.cart.client.domain.Cart cart)
    Intended for customization to support dynamic offers.
    protected void
    addPaymentsList(com.broadleafcommerce.promotion.offer.client.web.context.OrderDto orderDto, com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    If available, adds the payments from the cart into a structure that can be utilized during offer pricing to support payment specific offers.
    void
    applyOffers(@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 a Cart and its contents.
    void
    applyOffers(@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 a Cart and its contents.
    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)
     
    protected com.broadleafcommerce.pricing.client.domain.PriceInfo
    buildBasePriceInfoFromSale(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    protected Optional<com.broadleafcommerce.order.common.domain.CurrencyConversionDetail>
    buildCurrencyConversionDetail(com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment)
     
    protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ConvertedCurrencyDetail
    buildCurrencyConversionDetails(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Builds the ConvertedCurrencyDetail from the CartItem containing the currency conversion details.
    protected String
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected String
    buildCustomerContextHeader(com.broadleafcommerce.cart.client.domain.Cart cart)
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected String
    buildCustomerContextHeader(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Builds the CustomerContext header for the offer request.
    protected com.broadleafcommerce.promotion.offer.client.web.context.info.ExistingOfferRef
     
    protected com.broadleafcommerce.order.common.domain.Adjustment
    buildItemAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment, boolean isForFulfillment)
    Builds an Adjustment based on the given parameters for a CartItem or FulfillmentItem.
    protected com.broadleafcommerce.order.common.domain.ItemProrationDetail
    buildItemProrationDetail(com.broadleafcommerce.promotion.offer.client.web.context.info.ItemProrationDetail clientDetail)
    Builds an ItemProrationDetail based on the given ItemProrationDetail.
    protected com.broadleafcommerce.promotion.offer.client.web.context.RecurringPriceDetail
    buildLineItemRecurringPrice(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Converts the CartItem.getRecurringPrice() to the version used on LineItem.getStandardRecurringPrice().
    protected com.broadleafcommerce.promotion.offer.client.web.context.RecurringPriceDetail
    buildLineItemRecurringPrice(com.broadleafcommerce.pricing.client.domain.RecurringPriceDetail sourceDetail)
     
    protected 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.OfferRef
    buildOfferRef(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.ProratedOfferAdjustment
    buildProratedOrderAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment clientAdjustment)
    Builds an ProratedOfferAdjustment based on the given ProratedOfferAdjustment.
    protected com.broadleafcommerce.order.common.domain.RecurringPriceDetail
    buildRecurringPrice(@NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
    Converts the PriceInfo.getRecurringPrice() into the version used by CartItem.getRecurringPrice().
    protected com.broadleafcommerce.promotion.offer.client.web.context.SubscriptionItemDto
    Builds an instance of SubscriptionItemDto from the ExistingSubscriptionItemDetail
    protected com.broadleafcommerce.order.common.domain.UsagePriceDetail
    buildUsagePrice(@NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
    Converts the PriceInfo.getUsagePrice() into the version used by CartItem.getUsagePrice().
    protected com.broadleafcommerce.order.common.domain.Voucher
    buildVoucher(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef myItemOffer, com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher voucher)
    Builds a Voucher from the given Voucher.
    protected com.broadleafcommerce.order.common.domain.Voucher
    buildVoucher(com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher voucher)
    protected com.broadleafcommerce.promotion.offer.client.web.context.Destination
    convertAddressToDestination(@NonNull com.broadleafcommerce.order.common.domain.Address address)
    Converts an Address to a Destination.
    protected List<String>
    Extension point to handle converting complex characteristic values to a string representation.
    protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext
    createCustomerContext(com.broadleafcommerce.cart.client.domain.Cart cart)
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext
    createCustomerContext(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Create a CustomerContext and add customer and customer segments.
    protected String
    determineCurrentFlow(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Determines the current flow that the cart is in.
    protected List<com.broadleafcommerce.order.common.domain.Adjustment>
    getAdjustments(List<com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment> adjustments)
     
    protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
     
    protected com.broadleafcommerce.pricing.client.domain.PriceTypeDetail
    getBasePriceTypeDetail(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    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 of Adjustments for a CartItem based on the given ItemResponseDetail.
     
     
     
     
    protected Map<String,List<String>>
    getCharacteristics(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Builds a map of the attributes on cartItem that relate to Characteristics where Characteristic.isTargetableInRuleBuilders() is true.
    protected 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 promo code in the context of the given cart.
    protected BigDecimal
    Converts the currency exchange rate to a BigDecimal with a scale of 10.
    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 of Adjustments for a FulfillmentItem based on the given ItemResponseDetail.
    protected javax.money.MonetaryAmount
    getFulfillmentTotalBeforeAdjustments(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
     
    protected Object
    getProductType(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 of ProratedOfferAdjustments for a CartItem based on the given ItemResponse.
    protected String
     
    protected Optional<javax.money.MonetaryAmount>
    getStandardPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    protected Optional<com.broadleafcommerce.pricing.client.domain.RecurringPriceDetail>
    getStandardRecurringPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
     
    protected String
    getUserRefForReadingUserSubscriptionSummary(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
    The userRefType to query the Subscription-Ops service to group them into active and former subscriptions.
    protected String
    getUserRefTypeForReadingUserSubscriptionSummary(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
    The userRefType to query the Subscription-Ops service to group them into active and former subscriptions.
     
    protected List<com.broadleafcommerce.order.common.domain.Voucher>
    getVouchers(List<com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher> vouchers)
     
    protected boolean
    hasOverridePrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    protected boolean
    hasSalePrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    protected boolean
    hasStandardPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    protected boolean
    isFulfillmentItemForBundle(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.FulfillmentLineItemDto
    populateBundleFulfillmentLineItemDto(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.Codes
    populateCodes(com.broadleafcommerce.cart.client.domain.Cart cart)
    Deprecated.
    protected void
    populateCurrencyConversionDetails(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto lineItem)
    Populates the currency conversion details on the OrderLineItemDto from the CartItem.
    protected void
    populateDependentLineItemDto(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.cart.client.domain.CartItem parentItem, int overrideParentQuantity)
     
    protected void
    populateExistingOffers(@NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> orderDto, @NonNull ExistingSubscriptionDetails existingSubscriptionDetails, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Populates ExistingOfferRefs that the cart already has applied to the given OrderDto
    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.FulfillmentLineItemDto
    populateFulfillmentLineItemDto(Map<String,com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItemIdMap, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
     
    protected void
    populateFulfillmentServiceLevelData(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto> fgDto)
     
    protected com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto
    populateLineItemDto(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Returns a populated OrderLineItemDto from given CartItem.
    protected void
    populateLineItemDto(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Deprecated.
    in favor of populateLineItemDto(CartItem) for simpler client extension
    protected List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto>
    populateLineItems(com.broadleafcommerce.cart.client.domain.Cart cart)
     
    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.
    protected List<com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto>
    populateOfferCodes(com.broadleafcommerce.cart.client.domain.Cart cart)
     
    protected void
    populateOrderDtoFromUserSubscriptionSummary(@NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> orderDto, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull UserSubscriptionSummary subscriptionSummary, @NonNull String subscriptionActionFlow)
    Populates the details of the active and former subscriptions in the orderDto and filters out items that are already present in the cart.
    protected void
    populateSubscriptionDetails(@NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> orderDto, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Populates existing subscription details on the given OrderDto.
    protected void
    populateSubscriptionItemDtoFromUserSubscriptionSummary(@NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> orderDto, @NonNull UserSubscriptionSummary subscriptionSummary, boolean isForActiveSubscription)
    Populates the OrderDto.getActiveSubscriptionItems() or OrderDto.getFormerSubscriptionItems() from the UserSubscriptionSummary based on the isForActiveSubscription flag.
    protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto>
    void
    processFreeGiftOffers(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<T> orderResponse)
     
    void
    setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
     
    void
     
    void
     
    void
     
    void
     
    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.
    protected <T extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto>
    void
    updateCartForFulfillmentOffers(@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>
    void
    updateCartForOrderAndOrderItemOffers(@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>
    void
    updateCartItem(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<T> orderItemResponse, com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    Updates the CartItem with adjustment data from OfferService's ItemResponse.
    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)
     
    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)
     
    protected void
    updatePricingOnItem(com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> orderItemResponse)
    If the sale price was not used as the base price for the adjustment, we need to update the price infos on the cart item.
    com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult
    validateOfferAndOfferCodeUsages(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 java.lang.Object

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

  • 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: OfferProvider
      Handles requests against the Offer Engine to retrieve and apply discounts for a Cart and 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 to false if 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:
      applyOffers in interface OfferProvider
      Parameters:
      cart - The Cart whose contents to send to the offer engine for evaluation
      contextInfo - 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: OfferProvider
      Handles requests against the Offer Engine to retrieve and apply discounts for a Cart and its contents. Allows specifying whether order and order item offers will be applied in the calculation. Set runOrderAndItemOffers to false if 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:
      applyOffers in interface OfferProvider
      Parameters:
      cart - The Cart whose contents to send to the offer engine for evaluation
      runOrderAndItemOffers - Whether to have the Offer Engine run order and order item level offers. Set this to false if 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: OfferProvider
      Determines the usability type of the promo code in the context of the given cart. Possible values are defined in CodeUsabilityType and 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:
      getCodeUsabilityType in interface OfferProvider
      Parameters:
      code - The promo code to apply to cart
      cart - The Cart that promo code is to be applied to
      contextInfo - 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: OfferProvider
      Retrieve validation information regarding the cart's usage of the provided offers and offer codes to determine if the usage is still valid.
      Specified by:
      validateOfferAndOfferCodeUsages in interface OfferProvider
      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)
    • addPaymentsList

      protected void addPaymentsList(com.broadleafcommerce.promotion.offer.client.web.context.OrderDto orderDto, com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      If available, adds the payments from the cart into a structure that can be utilized during offer pricing to support payment specific offers.
      Parameters:
      orderDto - the order in which to populate the map
      cart - the related cart
      contextInfo - context information related to multitenancy
    • addDynamicOffersMap

      protected void addDynamicOffersMap(com.broadleafcommerce.promotion.offer.client.web.context.OrderDto orderDto, com.broadleafcommerce.cart.client.domain.Cart cart)
      Intended for customization to support dynamic offers. The implementor should populate the map with a key matching the dynamicOfferKey property from the Offer (see PromotionServices). An example use case could be an amount that is driven from an external loyalty system.
      Parameters:
      orderDto - the order in which to populate the map
      cart - the related cart
    • determineCurrentFlow

      @Nullable protected String determineCurrentFlow(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Determines the current flow that the cart is in.

      Currently, this is only used for subscriptions.

      Parameters:
      cart - the cart to determine the current flow for
      Returns:
      the current flow that the cart is in
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
      See Also:
    • populateSubscriptionDetails

      protected void populateSubscriptionDetails(@NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> orderDto, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Populates existing subscription details on the given OrderDto.
      Parameters:
      orderDto - the OrderDto to populate the existing offer refs for
      cart - the Cart containing details of the existing subscription
      contextInfo - the ContextInfo for the current request
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
    • populateOrderDtoFromUserSubscriptionSummary

      protected void populateOrderDtoFromUserSubscriptionSummary(@NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> orderDto, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull UserSubscriptionSummary subscriptionSummary, @NonNull @NonNull String subscriptionActionFlow)
      Populates the details of the active and former subscriptions in the orderDto and filters out items that are already present in the cart.

      This filtering will make the existing cart eligible for new subscriber offers.

      Parameters:
      orderDto - the OrderDto to populate the existing offer refs for
      cart - the Cart containing details of the existing subscription
      subscriptionSummary - the UserSubscriptionSummary for the current non-anonymous user
      subscriptionActionFlow - the subscription flow executing currently
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
    • populateSubscriptionItemDtoFromUserSubscriptionSummary

      protected void populateSubscriptionItemDtoFromUserSubscriptionSummary(@NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> orderDto, @NonNull @NonNull UserSubscriptionSummary subscriptionSummary, boolean isForActiveSubscription)
      Populates the OrderDto.getActiveSubscriptionItems() or OrderDto.getFormerSubscriptionItems() from the UserSubscriptionSummary based on the isForActiveSubscription flag.
      Parameters:
      orderDto - the order on which the active and former subscriptions would be set.
      subscriptionSummary - the UserSubscriptionSummary containing the active and former subscriptions.
      isForActiveSubscription - flag indicating whether the subscriptions are active or former.
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
    • buildSubscriptionItemDtoFromExistingSubscriptionItemDetail

      protected com.broadleafcommerce.promotion.offer.client.web.context.SubscriptionItemDto buildSubscriptionItemDtoFromExistingSubscriptionItemDetail(ExistingSubscriptionItemDetail itemDetail)
      Builds an instance of SubscriptionItemDto from the ExistingSubscriptionItemDetail
      Parameters:
      itemDetail - the itemDetail to be converted into a SubscriptionItemDto
      Returns:
      the converted SubscriptionItemDto
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
    • getUserRefTypeForReadingUserSubscriptionSummary

      protected String getUserRefTypeForReadingUserSubscriptionSummary(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
      The userRefType to query the Subscription-Ops service to group them into active and former subscriptions.
      Returns:
      the userRefType
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
    • getUserRefForReadingUserSubscriptionSummary

      protected String getUserRefForReadingUserSubscriptionSummary(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
      The userRefType to query the Subscription-Ops service to group them into active and former subscriptions.
      Returns:
      the userRefType
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
    • populateExistingOffers

      protected void populateExistingOffers(@NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> orderDto, @NonNull @NonNull ExistingSubscriptionDetails existingSubscriptionDetails, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Populates ExistingOfferRefs that the cart already has applied to the given OrderDto

      This is only relevant for subscriptions in a post-purchase flow, such as DefaultSubscriptionActionFlow.EDIT, to ensure that offers that are already applied to the subscription are not lost. For example, if a subscription has an offer applied for 10% off the VPN products, if the user upgrades from VPN-BASIC to VPN-PLUS (in an DefaultSubscriptionActionFlow.UPGRADE flow), the existing offer should still be applied.

      Parameters:
      orderDto - the OrderDto to populate the existing offer refs for
      existingSubscriptionDetails - the ExistingSubscriptionDetails containing details of already-applied adjustments
      contextInfo - the ContextInfo for the current request
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
    • buildExistingOfferRef

      protected com.broadleafcommerce.promotion.offer.client.web.context.info.ExistingOfferRef buildExistingOfferRef(@NonNull @NonNull ExistingAdjustmentDetail detail)
    • 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.
    • 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 DTO
      cart - 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, com.broadleafcommerce.cart.client.domain.CartItem parentItem, int overrideParentQuantity)
    • 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 of populateLineItemDto(CartItem) for simpler client extension
      Populates an OrderLineItemDto from given CartItem and adds it to the given list of OrderLineItemDtos.
      Parameters:
      lineItems - the list of OrderLineItemDtos to add the populated OrderLineItemDto to
      cartItem - the CartItem to populate an OrderLineItemDto from
    • populateLineItemDto

      protected com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto populateLineItemDto(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Returns a populated OrderLineItemDto from given CartItem.
      Parameters:
      cartItem - the CartItem to populate an OrderLineItemDto from
      Returns:
      populated OrderLineItemDto from given CartItem
    • getCharacteristics

      protected Map<String,List<String>> getCharacteristics(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Builds a map of the attributes on cartItem that relate to Characteristics where Characteristic.isTargetableInRuleBuilders() is true.
      Parameters:
      cartItem - The source CartItem.
      Returns:
      A map of the attributes on cartItem that relate to Characteristics where Characteristic.isTargetableInRuleBuilders() is true.
      Since:
      Cart Operation Service 2.2.0, Release Train 2.2.0
      See Also:
    • convertNonStringCharacteristicListToStringList

      protected List<String> convertNonStringCharacteristicListToStringList(@NonNull @NonNull List<?> values)
      Extension point to handle converting complex characteristic values to a string representation. By default, this just calls Object.toString() for each item.
      Parameters:
      values - The values to convert.
      Returns:
      The converted attribute.
      Since:
      Cart Operation Service 2.2.0, Release Train 2.2.0
      See Also:
    • buildLineItemRecurringPrice

      protected com.broadleafcommerce.promotion.offer.client.web.context.RecurringPriceDetail buildLineItemRecurringPrice(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Converts the CartItem.getRecurringPrice() to the version used on LineItem.getStandardRecurringPrice().
      Parameters:
      cartItem - Cart item that is the source of pricing.
      Returns:
      The Offer version of CartItem.getRecurringPrice().
    • buildLineItemRecurringPrice

      protected com.broadleafcommerce.promotion.offer.client.web.context.RecurringPriceDetail buildLineItemRecurringPrice(@Nullable com.broadleafcommerce.pricing.client.domain.RecurringPriceDetail sourceDetail)
    • 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)
    • populateFulfillmentServiceLevelData

      protected void populateFulfillmentServiceLevelData(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto> fgDto)
    • isFulfillmentItemForBundle

      protected boolean isFulfillmentItemForBundle(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, Map<String,com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItemIdMap)
    • getFulfillmentTotalBeforeAdjustments

      protected javax.money.MonetaryAmount getFulfillmentTotalBeforeAdjustments(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
    • convertAddressToDestination

      protected com.broadleafcommerce.promotion.offer.client.web.context.Destination convertAddressToDestination(@NonNull @NonNull com.broadleafcommerce.order.common.domain.Address address)
      Converts an Address to a Destination.
      Parameters:
      address - Address to be converted
      Returns:
      the Destination from the Address.
    • 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

      protected com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto populateFulfillmentLineItemDto(Map<String,com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItemIdMap, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
    • hasStandardPrice

      protected boolean hasStandardPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • hasSalePrice

      protected boolean hasSalePrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • hasOverridePrice

      protected boolean hasOverridePrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • getStandardPrice

      protected Optional<javax.money.MonetaryAmount> getStandardPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • getStandardRecurringPrice

      protected Optional<com.broadleafcommerce.pricing.client.domain.RecurringPriceDetail> getStandardRecurringPrice(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • populateCurrencyConversionDetails

      protected void populateCurrencyConversionDetails(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto lineItem)
      Populates the currency conversion details on the OrderLineItemDto from the CartItem.
      Parameters:
      cartItem - the CartItem containing the currency conversion details
      lineItem - the OrderLineItemDto to populate the currency conversion details on
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
      See Also:
    • buildCurrencyConversionDetails

      protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ConvertedCurrencyDetail buildCurrencyConversionDetails(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Builds the ConvertedCurrencyDetail from the CartItem containing the currency conversion details.
      Parameters:
      cartItem - the CartItem containing the currency conversion details
      Returns:
      the ConvertedCurrencyDetail containing the currency conversion details
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
      See Also:
    • getExchangeRateAsBigDecimal

      protected BigDecimal getExchangeRateAsBigDecimal(@NonNull @NonNull Object rate)
      Converts the currency exchange rate to a BigDecimal with a scale of 10. This is used when the ExchangeRateDetail on a CartItem has been converted to a map by the serialization process.
      Parameters:
      rate - the rate to convert
      Returns:
      the rate as a BigDecimal
      Throws:
      IllegalArgumentException - if the rate is not a valid date type and cannot be parsed
      Since:
      Cart Operation Service 2.3.0, Release Train 2.3.0
      See Also:
    • 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 didRunOrderAndItemOffers flag.

      Type Parameters:
      T - The specific type of ProratedItemOfferAdjustmentDto being used in the OrderResponse
      Parameters:
      cart - The cart containing the fulfillment groups being discounted
      orderResponse - The response from the offer engine after processing the cart to determine applicable discounts
      didRunOrderAndItemOffers - 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 from updateCartForOrderAndOrderItemOffers(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 of ProratedItemOfferAdjustmentDto being used in the OrderResponse
      Parameters:
      cart - The cart containing the fulfillment groups being discounted
      orderResponse - 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 from updateCartForFulfillmentOffers(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 of ProratedItemOfferAdjustmentDto being used in the OrderResponse
      Parameters:
      cart - The cart and its items being discounted
      orderResponse - 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

      protected List<com.broadleafcommerce.order.common.domain.Adjustment> getAdjustments(List<com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment> adjustments)
    • getVouchers

      protected List<com.broadleafcommerce.order.common.domain.Voucher> getVouchers(List<com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher> vouchers)
    • buildVoucher

      @Deprecated(forRemoval=true) protected com.broadleafcommerce.order.common.domain.Voucher buildVoucher(com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher voucher)
      Builds a Voucher from the given Voucher.
      Parameters:
      voucher - the Voucher to build the Voucher from
      Returns:
      a Voucher from the given Voucher
    • buildVoucher

      protected com.broadleafcommerce.order.common.domain.Voucher buildVoucher(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef myItemOffer, com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher voucher)
      Builds a Voucher from the given Voucher.
      Parameters:
      voucher - the Voucher to build the Voucher from
      Returns:
      a Voucher from the given Voucher
    • 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)
      Updates the CartItem with adjustment data from OfferService's ItemResponse.

      A dependent item's quantity and subtotal are defined on a "per-parent-unit" basis, meaning they are not scaled by parent's quantity. However, the ItemResponse.getSavings() is already scaled by the parent's quantity. To prevent negative totals on dependent items (where adjustmentsTotal > subtotal), the CartItem.getAdjustmentsTotal() is calculated separately based on the sum of the unit adjustment amount.

      Parameters:
      orderItemResponse - the response containing total savings from the offer engine
      cartItem - the cart item to update
      See Also:
      • for the parent-led scaling logic
    • updatePricingOnItem

      protected void updatePricingOnItem(com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustmentDto> orderItemResponse)
      If the sale price was not used as the base price for the adjustment, we need to update the price infos on the cart item.
      Parameters:
      cartItem - The item for which to update pricing details
    • getBasePriceTypeDetail

      protected com.broadleafcommerce.pricing.client.domain.PriceTypeDetail getBasePriceTypeDetail(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • buildBasePriceInfoFromSale

      protected com.broadleafcommerce.pricing.client.domain.PriceInfo buildBasePriceInfoFromSale(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • buildRecurringPrice

      protected com.broadleafcommerce.order.common.domain.RecurringPriceDetail buildRecurringPrice(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
      Converts the PriceInfo.getRecurringPrice() into the version used by CartItem.getRecurringPrice().
      Parameters:
      priceInfo - Source of the price.
      Returns:
      The converted RecurringPriceDetail.
      Since:
      Cart Operation Service 2.2.0, Release Train 2.2.0
    • buildUsagePrice

      protected com.broadleafcommerce.order.common.domain.UsagePriceDetail buildUsagePrice(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
      Converts the PriceInfo.getUsagePrice() into the version used by CartItem.getUsagePrice().
      Parameters:
      priceInfo - Source of the price.
      Returns:
      The converted UsagePriceDetail.
      Since:
      Cart Operation Service 2.2.0, Release Train 2.2.0
    • 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 of Adjustments for a CartItem based on the given ItemResponseDetail.
      Parameters:
      itemResponseDetail - the ItemResponseDetail to build the Adjustments from
      Returns:
      a list of Adjustments for a CartItem based on the given ItemResponseDetail
    • 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 of Adjustments for a FulfillmentItem based on the given ItemResponseDetail.
      Parameters:
      itemResponseDetail - the ItemResponseDetail to build the Adjustments from
      Returns:
      a list of Adjustments for a FulfillmentItem based on the given ItemResponseDetail
    • 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 an Adjustment based on the given parameters for a CartItem or FulfillmentItem.
      Parameters:
      offerAdjustment - the Adjustment to build it from
      isForFulfillment - whether the adjustment is for fulfillment item
      Returns:
      an Adjustment based on the given parameters for a CartItem or FulfillmentItem
    • buildCurrencyConversionDetail

      protected Optional<com.broadleafcommerce.order.common.domain.CurrencyConversionDetail> buildCurrencyConversionDetail(@NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment)
    • buildOfferItemDetails

      protected 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
    • 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 of ProratedOfferAdjustments for a CartItem based on the given ItemResponse.
      Parameters:
      orderItemResponse - the ItemResponse to build the ProratedOfferAdjustments from
      Returns:
      a list of ProratedOfferAdjustments for a CartItem based on the given ItemResponse
    • buildProratedOrderAdjustment

      protected com.broadleafcommerce.order.common.domain.ProratedOfferAdjustment buildProratedOrderAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment clientAdjustment)
      Builds an ProratedOfferAdjustment based on the given ProratedOfferAdjustment.
      Parameters:
      clientAdjustment - the ProratedOfferAdjustment to build it from
      Returns:
      an ProratedOfferAdjustment based on the given ProratedOfferAdjustment
    • buildItemProrationDetail

      protected com.broadleafcommerce.order.common.domain.ItemProrationDetail buildItemProrationDetail(com.broadleafcommerce.promotion.offer.client.web.context.info.ItemProrationDetail clientDetail)
      Builds an ItemProrationDetail based on the given ItemProrationDetail.
      Parameters:
      clientDetail - the ItemProrationDetail to build it from
      Returns:
      an ItemProrationDetail based on the given ItemProrationDetail
    • buildCustomerContextHeader

      @Deprecated(forRemoval=true) protected String buildCustomerContextHeader()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • buildCustomerContextHeader

      @Deprecated(forRemoval=true) protected String buildCustomerContextHeader(@Nullable com.broadleafcommerce.cart.client.domain.Cart cart)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • buildCustomerContextHeader

      protected String buildCustomerContextHeader(@Nullable com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Builds the CustomerContext header for the offer request.
      Parameters:
      cart - The cart being priced.
      contextInfo - Additional sandbox and tenant info.
      Returns:
      The CustomerContext header for the offer request.
    • createCustomerContext

      @Deprecated(forRemoval=true) protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext createCustomerContext()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createCustomerContext

      @Deprecated(forRemoval=true) protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext createCustomerContext(@Nullable com.broadleafcommerce.cart.client.domain.Cart cart)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createCustomerContext

      protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext createCustomerContext(@Nullable com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Create a CustomerContext and add customer and customer segments. Uses the current authentication token to determine principal and details.
      Parameters:
      cart -
      contextInfo - The context information with customer segments
      Returns:
      The created CustomerContext
    • getCodeUsabilityInfoMap

      protected org.springframework.core.ParameterizedTypeReference<Map<String,com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo>> getCodeUsabilityInfoMap()
    • getServiceClient

      protected String getServiceClient()
    • getUserTargetGenerationService

      protected UserTargetGenerationService getUserTargetGenerationService()
    • getCartTotalsCalculator

      protected CartTotalsCalculator getCartTotalsCalculator()
    • getCartOpsServiceOfferUtils

      protected CartOperationServiceOfferUtils getCartOpsServiceOfferUtils()
    • setCartOpsServiceOfferUtils

      @Autowired public void setCartOpsServiceOfferUtils(CartOperationServiceOfferUtils cartOpsServiceOfferUtils)
    • getCartOpProperties

      protected CartOperationServiceProperties getCartOpProperties()
    • setCartOpProperties

      @Autowired public void setCartOpProperties(CartOperationServiceProperties cartOpProperties)
    • getAuthenticationUtils

      protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils()
    • setAuthenticationUtils

      @Autowired public void setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
    • getCartSubscriptionUtils

      protected CartSubscriptionUtils getCartSubscriptionUtils()
    • setCartSubscriptionUtils

      @Autowired public void setCartSubscriptionUtils(CartSubscriptionUtils cartSubscriptionUtils)
    • getSubscriptionOpsProvider

      @Nullable protected SubscriptionOpsProvider getSubscriptionOpsProvider()
    • setSubscriptionOpsProvider

      @Autowired(required=false) public void setSubscriptionOpsProvider(@Nullable SubscriptionOpsProvider subscriptionOpsProvider)