Class DefaultFulfillmentOptionRequestService

java.lang.Object
com.broadleafcommerce.cartoperation.service.fulfillment.option.DefaultFulfillmentOptionRequestService
All Implemented Interfaces:
FulfillmentOptionRequestService

public class DefaultFulfillmentOptionRequestService extends Object implements FulfillmentOptionRequestService
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultFulfillmentOptionRequestService(FulfillmentGroupService fulfillmentGroupService, FulfillmentPricingConfigHelperService configHelper, CartOperationServiceProviders providers, CartPricingService cartPricingService, com.fasterxml.jackson.databind.ObjectMapper mapper, org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addAddressToGroups(com.broadleafcommerce.order.common.domain.Address orderAddress, boolean overwrite, com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Set the given address on any fulfillment group that does not have an address set.
    protected void
    addFulfillmentOptionToTarget(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.order.common.domain.PricedFulfillmentOption pricedFulfillmentOption, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Add the PricedFulfillmentOption selected by the user to the corresponding FulfillmentGroup or FulfillmentItem.
    protected void
    applySelectionErrors(Map<String,Object> selectionErrors, com.broadleafcommerce.cart.client.domain.Cart updatedCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    buildCartFulfillmentResponse(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse pricingFulfillmentOptions, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionRequest
    buildFulfillmentOptionRequest(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, boolean onlySelectedOptions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Create pricing groups from the cart and build the FulfillmentOptionRequest.
    protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionRequest
    buildFulfillmentOptionRequest(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Deprecated.
    In favor of the version that takes the onlySelectedOptions parameter: buildFulfillmentOptionRequest(Cart, FulfillmentPricingConfig, boolean onlySelectedOptions, ContextInfo)
    protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingGroup
    buildFulfillmentPricingGroup(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Map<String,com.broadleafcommerce.cart.client.domain.CartItem> cartItemMap, com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
     
    protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem
    buildFulfillmentPricingItem(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Map<String,com.broadleafcommerce.cart.client.domain.CartItem> cartItemMap, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, String type)
     
    calculateOptionsAndGroups(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.Address defaultAddress, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Convenience method to get all fulfillment options for an address and assign defaults.
    protected Map<String,Object>
    collectSelectionErrors(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    protected com.broadleafcommerce.fulfillment.common.domain.Address
    convertToFulfillmentAddress(com.broadleafcommerce.order.common.domain.Address orderAddress, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    protected com.broadleafcommerce.order.common.domain.Address
    convertToOrderAddress(com.broadleafcommerce.fulfillment.common.domain.Address fulfillmentAddress, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionRequest
    createRequest(com.broadleafcommerce.cart.client.domain.Cart cart, Collection<com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingGroup> fulfillmentPricingGroups, boolean onlySelectedOptions, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Create a new FulfillmentOptionRequest and populate with the given data.
    protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionRequest
    createRequest(com.broadleafcommerce.cart.client.domain.Cart cart, Collection<com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingGroup> fulfillmentPricingGroups, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Deprecated.
    In favor of the version that takes the onlySelectedOptions parameter: createRequest(Cart, Collection, boolean onlySelectedOptions, FulfillmentPricingConfig, ContextInfo)
    protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse
    fetchFulfillmentOptions(com.broadleafcommerce.cart.client.domain.Cart cart, boolean onlySelectedOptions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Fetch fulfillment options from the FulfillmentProvider.
    com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig
    fetchFulfillmentPriceConfig(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Fetch the FulfillmentPricingConfig from the FulfillmentProvider.
    protected Optional<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption>
    findLeastExpensiveOptionForFulType(String fulfillmentType, List<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption> pricedFulfillmentOptions)
     
    protected Map<String,com.broadleafcommerce.cart.client.domain.CartItem>
    getCartItemMap(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Get Map of CartItem ID to CartItem
     
     
    protected String
     
    protected com.broadleafcommerce.fulfillment.common.domain.Dimensions
    getDimension(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    protected Map<String,javax.money.MonetaryAmount>
    getFlatRates(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
     
    com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse
    getFulfillmentOptionsForCart(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Fetch all available fulfillment options for the given cart.
    protected Collection<? extends com.broadleafcommerce.fulfillment.common.domain.FulfillmentOriginInfo>
    getFulfillmentOriginInfos(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    protected com.broadleafcommerce.fulfillment.common.domain.Weight
    getFulfillmentWeight(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    protected com.fasterxml.jackson.databind.ObjectMapper
     
    protected org.springframework.context.MessageSource
     
     
    protected com.broadleafcommerce.common.extension.TypeFactory
     
    protected com.broadleafcommerce.order.common.domain.PricedFulfillmentOption
    getUpdatedPFO(com.broadleafcommerce.order.common.domain.PricedFulfillmentOption selectedOption, List<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption> pricedFulfillmentOptions, Runnable configErrorCallback, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Get the up-to-date PricedFulfillmentOption that corresponds to the selectedOption.
    protected Weight
    getWeight(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
     
    protected boolean
    matchesByServiceLevel(com.broadleafcommerce.order.common.domain.PricedFulfillmentOption selectedPricedFulfillmentOption, com.broadleafcommerce.order.common.domain.PricedFulfillmentOption candidateOption, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Determine if two PricedFulfillmentOptions have the same Fulfillment Type and Service Level.
    protected boolean
    matchesSelectedOption(com.broadleafcommerce.order.common.domain.PricedFulfillmentOption selectedPricedFulfillmentOption, com.broadleafcommerce.order.common.domain.PricedFulfillmentOption candidateOption, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Determine if two PricedFulfillmentOptions have the same Fulfillment Type, Service Level, and Provider ID
    void
    refreshOptions(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Refresh the selected PricedFulfillmentOptions on the cart.
    refreshOptionsAndGroups(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Refresh the selected fulfillment options, save the cart, and return the cart with all fulfillment options.
    protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse
    refreshOptionsAndSyncGroups(com.broadleafcommerce.cart.client.domain.Cart cart, boolean onlySelectedOptions, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Fetch up-to-date PricedFulfillmentOptions and replace the corresponding options selected on the Cart with the updated version.
    protected void
    refreshOptionsForGroups(com.broadleafcommerce.cart.client.domain.Cart cart, Map<String,List<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption>> fulRefToOpts, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    protected void
    refreshOptionsForItems(com.broadleafcommerce.cart.client.domain.Cart cart, Map<String,List<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption>> fulRefToOpts, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    protected void
    refreshSelectedOptions(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse fulfillmentOptionResponse, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Update the PricedFulfillmentOption selections on the cart to the latest versions from the FulfillmentOptionResponse.
    protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse
    refreshSelectedOptionsAndGrouping(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Deprecated.
    In favor of the refreshOptionsAndSyncGroups that takes the onlySelectedOptions parameter: refreshOptionsAndSyncGroups(Cart, boolean onlySelectedOptions, FulfillmentPricingConfig, ContextInfo)
    protected com.broadleafcommerce.cart.client.domain.Cart
    saveCart(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    protected void
    setConfigWarning(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
     
    protected void
    setConfigWarning(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
     
    submitFulfillmentOption(com.broadleafcommerce.order.common.domain.PricedFulfillmentOption pricedFulfillmentOption, com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Attaches given PricedFulfillmentOptions to their corresponding fulfillment item or group, then sorts the items into new fulfillment groups
    updateFulfillmentGroupAddress(String referenceId, com.broadleafcommerce.fulfillment.common.domain.Address address, com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Update the Address of a FulfillmentGroup and refresh fulfillment options.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • getFulfillmentOptionsForCart

      public com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse getFulfillmentOptionsForCart(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: FulfillmentOptionRequestService
      Fetch all available fulfillment options for the given cart.
      Specified by:
      getFulfillmentOptionsForCart in interface FulfillmentOptionRequestService
      Parameters:
      cart - The cart to retrieve fulfillment options for.
      contextInfo - The context of the request.
      Returns:
      A FulfillmentOptionResponse with PricedFulfillmentOption for either each item or each group, depending on configuration.
    • submitFulfillmentOption

      public CartFulfillmentResponse submitFulfillmentOption(com.broadleafcommerce.order.common.domain.PricedFulfillmentOption pricedFulfillmentOption, com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Attaches given PricedFulfillmentOptions to their corresponding fulfillment item or group, then sorts the items into new fulfillment groups
      Specified by:
      submitFulfillmentOption in interface FulfillmentOptionRequestService
      Parameters:
      pricedFulfillmentOption -
      cart -
      contextInfo -
      Returns:
    • calculateOptionsAndGroups

      public CartFulfillmentResponse calculateOptionsAndGroups(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.fulfillment.common.domain.Address defaultAddress, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: FulfillmentOptionRequestService
      Convenience method to get all fulfillment options for an address and assign defaults. The address argument is optional and will be applied to any FulfillmentGroups that do not already have an address.
      Specified by:
      calculateOptionsAndGroups in interface FulfillmentOptionRequestService
      Parameters:
      cart - The cart to whose items or groups will be used to fetch fulfillment options.
      defaultAddress - An optional Address to assign to any FulfillmentGroup that does not have an address already.
      contextInfo - The context of the request.
      Returns:
      A CartFulfillmentResponse that includes the available PricedFulfillmentOptions and an updated cart with default fulfillment options assigned to the targets.
    • updateFulfillmentGroupAddress

      public CartFulfillmentResponse updateFulfillmentGroupAddress(String referenceId, com.broadleafcommerce.fulfillment.common.domain.Address address, com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: FulfillmentOptionRequestService

      Update the Address of a FulfillmentGroup and refresh fulfillment options.

      This method is intended for updating an Address outside the checkout flow, in order to get updated fulfillment options on a non-checkout page. Within a checkout flow, use CheckoutCartEndpoint#updateFulfillmentGroupInCart to ensure all the fields required for checkout are populated.

      Specified by:
      updateFulfillmentGroupAddress in interface FulfillmentOptionRequestService
      Parameters:
      referenceId - The reference id of the FulfillmentGroup to update.
      address - The Address to assign to the indicated FulfillmentGroup.
      cart - The cart that contains the indicated FulfillmentGroup.
      contextInfo - The context of the request.
      Returns:
      A CartFulfillmentResponse that includes the available PricedFulfillmentOptions for the given address and an updated cart with valid fulfillment options assigned to the targets.
    • fetchFulfillmentPriceConfig

      public com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig fetchFulfillmentPriceConfig(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: FulfillmentOptionRequestService
      Fetch the FulfillmentPricingConfig from the FulfillmentProvider.
      Specified by:
      fetchFulfillmentPriceConfig in interface FulfillmentOptionRequestService
      Parameters:
      contextInfo - The context of the request.
      Returns:
      The FulfillmentPricingConfig for the given context.
    • refreshOptions

      public void refreshOptions(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: FulfillmentOptionRequestService

      Refresh the selected PricedFulfillmentOptions on the cart. Up-to-date options will be retrieved from the FulfillmentProvider for the selected options on the cart.

      The selected PricedFulfillmentOptions on items and groups will be updated with an option that matches Fulfillment Type, Service Level, and Provider ID. If for any reason an exact match is not found, fallback logic will be used to determine an appropriate replacement.

      Specified by:
      refreshOptions in interface FulfillmentOptionRequestService
      Parameters:
      cart - The cart whose fulfillment options should be refreshed.
      contextInfo - The context of the request.
    • fetchFulfillmentOptions

      protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse fetchFulfillmentOptions(com.broadleafcommerce.cart.client.domain.Cart cart, boolean onlySelectedOptions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Fetch fulfillment options from the FulfillmentProvider.
      Parameters:
      cart - The cart being priced.
      onlySelectedOptions - Indicate if all available fulfillment service levels should be fetched, or only the service level(s) that are selected on the cart.
      contextInfo - The contextInfo of the request.
      Returns:
      The FulfillmentOptionResponse that contains the PricedFulfillmentOptions for the given cart.
    • buildFulfillmentOptionRequest

      @Deprecated protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionRequest buildFulfillmentOptionRequest(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated.
      In favor of the version that takes the onlySelectedOptions parameter: buildFulfillmentOptionRequest(Cart, FulfillmentPricingConfig, boolean onlySelectedOptions, ContextInfo)
      Create pricing groups from the cart and build the FulfillmentOptionRequest.
      Parameters:
      cart - The cart being priced.
      config - The FulfillmentPricingConfig associated with the given contextInfo.
      contextInfo - The contextInfo of the request.
      Returns:
      The FulfillmentOptionRequest to send to the FulfillmentProvider.
    • buildFulfillmentOptionRequest

      protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionRequest buildFulfillmentOptionRequest(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, boolean onlySelectedOptions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Create pricing groups from the cart and build the FulfillmentOptionRequest.
      Parameters:
      cart - The cart being priced.
      config - The FulfillmentPricingConfig associated with the given contextInfo.
      onlySelectedOptions - Indicate if all available fulfillment service levels should be fetched, or only the service level(s) that are selected on the cart.
      contextInfo - The contextInfo of the request.
      Returns:
      The FulfillmentOptionRequest to send to the FulfillmentProvider.
    • buildFulfillmentPricingGroup

      protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingGroup buildFulfillmentPricingGroup(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Map<String,com.broadleafcommerce.cart.client.domain.CartItem> cartItemMap, com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
    • buildFulfillmentPricingItem

      protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem buildFulfillmentPricingItem(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Map<String,com.broadleafcommerce.cart.client.domain.CartItem> cartItemMap, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, String type)
    • getFulfillmentOriginInfos

      protected Collection<? extends com.broadleafcommerce.fulfillment.common.domain.FulfillmentOriginInfo> getFulfillmentOriginInfos(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getFlatRates

      protected Map<String,javax.money.MonetaryAmount> getFlatRates(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getFulfillmentWeight

      protected com.broadleafcommerce.fulfillment.common.domain.Weight getFulfillmentWeight(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • getWeight

      @Nullable protected Weight getWeight(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • getDimension

      @Nullable protected com.broadleafcommerce.fulfillment.common.domain.Dimensions getDimension(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
    • createRequest

      @Deprecated protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionRequest createRequest(com.broadleafcommerce.cart.client.domain.Cart cart, Collection<com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingGroup> fulfillmentPricingGroups, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated.
      In favor of the version that takes the onlySelectedOptions parameter: createRequest(Cart, Collection, boolean onlySelectedOptions, FulfillmentPricingConfig, ContextInfo)
      Create a new FulfillmentOptionRequest and populate with the given data.
      Parameters:
      cart - The cart being priced.
      fulfillmentPricingGroups - The FulfillmentPricingGroups to be added to the new request.
      config - The FulfillmentPricingConfig associated with the given contextInfo.
      contextInfo - The contextInfo of the request.
      Returns:
      The FulfillmentOptionRequest to send to the FulfillmentProvider.
    • createRequest

      protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionRequest createRequest(com.broadleafcommerce.cart.client.domain.Cart cart, Collection<com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingGroup> fulfillmentPricingGroups, boolean onlySelectedOptions, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Create a new FulfillmentOptionRequest and populate with the given data.
      Parameters:
      cart - The cart being priced.
      fulfillmentPricingGroups - The FulfillmentPricingGroups to be added to the new request.
      onlySelectedOptions - Indicate if all available fulfillment service levels should be fetched, or only the service level(s) that are selected on the cart.
      config - The FulfillmentPricingConfig associated with the given contextInfo.
      contextInfo - The contextInfo of the request.
      Returns:
      The FulfillmentOptionRequest to send to the FulfillmentProvider.
    • addAddressToGroups

      protected void addAddressToGroups(com.broadleafcommerce.order.common.domain.Address orderAddress, boolean overwrite, com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Set the given address on any fulfillment group that does not have an address set. If the override flag is true, then update the address on all groups, even if the group already has an address.
      Parameters:
      orderAddress -
      cart - The cart whose FulfillmentGroups will be checked.
      contextInfo -
    • refreshOptionsAndGroups

      protected CartFulfillmentResponse refreshOptionsAndGroups(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Refresh the selected fulfillment options, save the cart, and return the cart with all fulfillment options.
      Parameters:
      cart - The cart being priced.
      config - The FulfillmentPricingConfig associated with the given contextInfo.
      contextInfo - The contextInfo of the request.
      Returns:
      A CartFulfillmentResponse containing the updated cart and a FulfillmentOptionResponse with up-to-date fulfillment options.
    • refreshSelectedOptionsAndGrouping

      @Deprecated protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse refreshSelectedOptionsAndGrouping(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated.
      In favor of the refreshOptionsAndSyncGroups that takes the onlySelectedOptions parameter: refreshOptionsAndSyncGroups(Cart, boolean onlySelectedOptions, FulfillmentPricingConfig, ContextInfo)
      Fetch up-to-date PricedFulfillmentOptions and replace the corresponding options selected on the Cart with the updated version.
      Parameters:
      cart - The cart being priced.
      config - The FulfillmentPricingConfig associated with the given contextInfo.
      contextInfo - The contextInfo of the request.
      Returns:
      The FulfillmentOptionResponse that was fetched during the refresh. Depending on the value of the onlySelectedOptions parameter, it may contain all available fulfillment options, or only the updated versions of selected options.
    • refreshOptionsAndSyncGroups

      protected com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse refreshOptionsAndSyncGroups(com.broadleafcommerce.cart.client.domain.Cart cart, boolean onlySelectedOptions, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Fetch up-to-date PricedFulfillmentOptions and replace the corresponding options selected on the Cart with the updated version.
      Parameters:
      cart - The cart being priced.
      onlySelectedOptions - Indicate if the fetch operation should fetch updated PricedFulfillmentOptions for only the service levels selected in the Cart, or for all available service levels.
      config - The FulfillmentPricingConfig associated with the given contextInfo.
      contextInfo - The contextInfo of the request.
      Returns:
      The FulfillmentOptionResponse that was fetched during the refresh. Depending on the value of the onlySelectedOptions parameter, it may contain all available fulfillment options, or only the updated versions of selected options.
    • refreshSelectedOptions

      protected void refreshSelectedOptions(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse fulfillmentOptionResponse, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Update the PricedFulfillmentOption selections on the cart to the latest versions from the FulfillmentOptionResponse.
      Parameters:
      cart - The cart being priced.
      fulfillmentOptionResponse - Contains the PricedFulfillmentOptions for the cart.
      config - The FulfillmentPricingConfig associated with the given contextInfo.
      contextInfo - The contextInfo of the request.
    • refreshOptionsForGroups

      protected void refreshOptionsForGroups(com.broadleafcommerce.cart.client.domain.Cart cart, Map<String,List<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption>> fulRefToOpts, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • refreshOptionsForItems

      protected void refreshOptionsForItems(com.broadleafcommerce.cart.client.domain.Cart cart, Map<String,List<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption>> fulRefToOpts, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getUpdatedPFO

      @Nullable protected com.broadleafcommerce.order.common.domain.PricedFulfillmentOption getUpdatedPFO(com.broadleafcommerce.order.common.domain.PricedFulfillmentOption selectedOption, List<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption> pricedFulfillmentOptions, Runnable configErrorCallback, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Get the up-to-date PricedFulfillmentOption that corresponds to the selectedOption. If an exact match is not found, fall back to the least expensive option that matches the selected option's FulfillmentType. If there is still no match, fall back to the default FulfillmentType. Returns null if no suitable fallback is found.
      Parameters:
      selectedOption - The stale PricedFulfillmentOption that is attached to a group or item.
      pricedFulfillmentOptions - The available PricedFulfillmentOptions for this group or item.
      configErrorCallback - A Runnable to execute if an exact match is not found. This is intended to call out to the appropriate setConfigWarning method to set a warning message for the user.
      contextInfo - The contextInfo of the request.
      Returns:
      The up-to-date PricedFulfillmentOption that corresponds to the given selectedOption.
    • findLeastExpensiveOptionForFulType

      protected Optional<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption> findLeastExpensiveOptionForFulType(String fulfillmentType, List<com.broadleafcommerce.order.common.domain.PricedFulfillmentOption> pricedFulfillmentOptions)
    • saveCart

      protected com.broadleafcommerce.cart.client.domain.Cart saveCart(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • collectSelectionErrors

      protected Map<String,Object> collectSelectionErrors(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • applySelectionErrors

      protected void applySelectionErrors(Map<String,Object> selectionErrors, com.broadleafcommerce.cart.client.domain.Cart updatedCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildCartFulfillmentResponse

      protected CartFulfillmentResponse buildCartFulfillmentResponse(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.fulfillment.common.domain.FulfillmentOptionResponse pricingFulfillmentOptions, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • setConfigWarning

      protected void setConfigWarning(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
    • setConfigWarning

      protected void setConfigWarning(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
    • addFulfillmentOptionToTarget

      protected void addFulfillmentOptionToTarget(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.order.common.domain.PricedFulfillmentOption pricedFulfillmentOption, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Add the PricedFulfillmentOption selected by the user to the corresponding FulfillmentGroup or FulfillmentItem.
      Parameters:
      cart - The cart whose FulfillmentGroups or FulfillmentItems are being targeted for fulfillment.
      pricedFulfillmentOption - The PricedFulfillmentOption selected by the user.
    • matchesSelectedOption

      protected boolean matchesSelectedOption(com.broadleafcommerce.order.common.domain.PricedFulfillmentOption selectedPricedFulfillmentOption, com.broadleafcommerce.order.common.domain.PricedFulfillmentOption candidateOption, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Determine if two PricedFulfillmentOptions have the same Fulfillment Type, Service Level, and Provider ID
      Parameters:
      selectedPricedFulfillmentOption -
      candidateOption -
      contextInfo -
      Returns:
    • matchesByServiceLevel

      protected boolean matchesByServiceLevel(com.broadleafcommerce.order.common.domain.PricedFulfillmentOption selectedPricedFulfillmentOption, com.broadleafcommerce.order.common.domain.PricedFulfillmentOption candidateOption, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Determine if two PricedFulfillmentOptions have the same Fulfillment Type and Service Level.
      Parameters:
      selectedPricedFulfillmentOption -
      candidateOption -
      contextInfo -
      Returns:
    • getCartItemMap

      protected Map<String,com.broadleafcommerce.cart.client.domain.CartItem> getCartItemMap(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Get Map of CartItem ID to CartItem
      Parameters:
      cart - The cart whose items should be put into the map
      contextInfo - Request and user context
      Returns:
      Map of CartItem ID to CartItem for the given cart.
    • convertToOrderAddress

      protected com.broadleafcommerce.order.common.domain.Address convertToOrderAddress(com.broadleafcommerce.fulfillment.common.domain.Address fulfillmentAddress, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • convertToFulfillmentAddress

      protected com.broadleafcommerce.fulfillment.common.domain.Address convertToFulfillmentAddress(com.broadleafcommerce.order.common.domain.Address orderAddress, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getDefaultFulfillmentType

      protected String getDefaultFulfillmentType()
    • getFulfillmentGroupService

      protected FulfillmentGroupService getFulfillmentGroupService()
    • getConfigHelper

      protected FulfillmentPricingConfigHelperService getConfigHelper()
    • getProviders

      protected CartOperationServiceProviders getProviders()
    • getCartPricingService

      protected CartPricingService getCartPricingService()
    • getMapper

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

      protected org.springframework.context.MessageSource getMessageSource()
    • getTypeFactory

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