Class DefaultCartOperationService
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.DefaultCartOperationService
-
- All Implemented Interfaces:
CartOperationService
public class DefaultCartOperationService extends Object implements CartOperationService
- Author:
- Chad Harchar (charchar)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultCartOperationService.BulkCartItemCreationResponse
-
Constructor Summary
Constructors Constructor Description DefaultCartOperationService(CartOperationServiceProviders providers, CartPricingService cartPricingService, CartItemConfigurationService cartItemConfigurationService, CartItemProductService cartItemProductService, com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartOperationServiceProperties properties, CartItemMergingService<com.broadleafcommerce.cart.client.domain.CartItem> cartItemMergingService, org.springframework.context.MessageSource messageSource, TaxService taxService, StaleCartPricingResultHolder staleCartPricingResultHolder)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description com.broadleafcommerce.cart.client.domain.Cart
addAttributeToCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull AddAttributeRequest addAttributeRequest, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds an attribute to the providedCart
.protected boolean
addCampaignForCodeIfExists(String code, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds acode
to theCart
if it belongs to a campaign.AddCodeToCartResponse
addCodeToCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull AddCodeRequest codeRequest, boolean allowPriceCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the cart Determine if the code is valid as a campaign tracking code If so, add it to the cart as aCampaignRef
Determine if the code is valid as a shared code If so, add it to the cart Update the cart Price the cart, using offers and price lists (optional) Update the cart and its items (optional)protected void
addFreeGiftItemsToCart(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem> freeGiftItemsToAdd, List<com.broadleafcommerce.cart.client.domain.CartItem> updatedCartItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds the list ofFreeGiftItems
to cart, and then adds the ids of those added free gift cart items to the qualifier cart items attributes.protected void
addItemsToFulfillmentGroup(@NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull javax.money.CurrencyUnit expectedCurrency)
Deprecated.protected void
addItemsToFulfillmentGroup(@NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull javax.money.CurrencyUnit expectedCurrency, com.broadleafcommerce.cart.client.domain.CartItem parentCartItem)
com.broadleafcommerce.cart.client.domain.Cart
addItemToCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull AddItemRequest addItemRequest, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds a single item to the providedCart
based on the providedAddItemRequest
.protected void
addItemToFulfillmentGroup(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Deprecated.protected void
addItemToFulfillmentGroup(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, Set<String> assignedCartItemIds, com.broadleafcommerce.cart.client.domain.CartItem parentCartItem)
Assigns the cart item and its dependent cart items to the fulfillment group.BulkAddToCartResponse
addManyItemsToCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Collection<AddItemRequest> addItemRequests, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds one or more items to the providedCart
.protected boolean
addOfferCodeIfUsable(String code, boolean isForCampaign, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds thecode
toCart.getOfferCodes()
if it's usable.AddCodeToCartResponse
addOfferCodeToCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull AddCodeRequest addOfferCodeRequest, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds an offer code to the providedCart
.protected void
addRemovedFreeGiftOfferToIgnoreList(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> cartItemsBeingRemoved)
Adds the offer id toCart's
ignore list inCart.getInternalAttributes()
whenever a free gift item is removed, so that the free gift item will not be added again.com.broadleafcommerce.cart.client.domain.Cart
addToCart(@NonNull AddItemRequest addItemRequest, com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.order.common.domain.CustomerRef customerRef, boolean allowPriceCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Add an item to the customer's current cart based on the provided untrusted information.protected com.broadleafcommerce.cart.client.domain.Cart
addUnassignedItemsToFulfillmentGroup(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
IdentifyCartItems
that have not been assigned to aFulfillmentGroup
& add them to the relevant FulfillmentGroup.protected PaymentSummary
allocateCartTotalToPayment(@NonNull PaymentSummary paymentSummary, @NonNull javax.money.MonetaryAmount cartTotal, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Hook point to automatically reallocate the cart total to the cart's single payment.protected AddCodeToCartResponse
buildAddCodeToCartResponse(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String code, boolean cartWasRepriced)
Builds anAddCodeToCartResponse
based on the provided cart, code, & whether or not the cart was repricedprotected AddItemRequest
buildAddItemRequest(com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem freeGiftItem)
Builds anAddItemRequest
from the givenFreeGiftItem
.protected com.broadleafcommerce.order.common.domain.Adjustment
buildAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment)
Builds anAdjustment
based on the givenAdjustment
.protected com.broadleafcommerce.order.common.domain.CampaignRef
buildCampaignRef(String code, String trackingId)
protected com.broadleafcommerce.cart.client.domain.CartItem
buildCartItem(@NonNull AddItemRequest addItemRequest, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected com.broadleafcommerce.cart.client.domain.CartItem
buildCartItem(@NonNull AddItemRequest addItemRequest, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, javax.money.CurrencyUnit currencyUnit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Populates a new cart item from theAddItemRequest
.protected DefaultCartOperationService.BulkCartItemCreationResponse
buildCartItems(@NonNull Collection<AddItemRequest> addItemRequests, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected DefaultCartOperationService.BulkCartItemCreationResponse
buildCartItems(@NonNull Collection<AddItemRequest> addItemRequests, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, javax.money.CurrencyUnit currencyUnit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Populates new cart items from theAddItemRequests
.protected String
buildGroupReferenceNumber(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Builds aFulfillmentGroup.getReferenceNumber()
for a new group.protected String
buildGroupReferenceNumber(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String fulfillmentGroupId)
Builds aFulfillmentGroup.getReferenceNumber()
for the given cart and group ID.protected com.broadleafcommerce.cart.client.domain.ConfigError
buildInventoryUnavailableError()
protected Map<String,com.broadleafcommerce.order.common.domain.AttributeChoiceValue>
buildItemAttributeChoices(@NonNull Map<String,String> requestItemAttributeChoices)
protected com.broadleafcommerce.order.common.domain.OfferItemDetail
buildOfferItemDetails(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferItemDetail offerItemDetail)
Builds anOfferItemDetail
from the givenOfferItemDetail
.protected AddItemFailure
buildValidationFailure(@NonNull AddItemRequest addItemRequest, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Builds anAddItemFailure
based on the providedAddItemRequest
&CartItem
representing an invalid add to cart requestBulkAddToCartResponse
bulkAddToCart(@NonNull Collection<AddItemRequest> addItemRequests, com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.order.common.domain.CustomerRef customerRef, boolean allowPriceCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Add a list of items to the customer's current cart based on the provided untrusted information.protected int
calculateDependentItemsQuantityWithSameSku(@NonNull com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, int parentQuantity)
protected int
calculateItemsQuantityWithSameSku(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
protected int
calculateItemsQuantityWithSameSku(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, int parentItemQuantity)
protected void
checkDependentItemInternalInventoryAvailability(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Product product, @NonNull com.broadleafcommerce.cart.client.domain.CartItem dependantCartItem, @NonNull Product dependentProduct)
Checks the inventory-related fields in the catalog data to determine whether or not the dependent item is available.protected void
checkInternalInventoryAvailability(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Product product, @NonNull List<Product> products)
Checks the inventory-related fields in the catalog data to determine whether or not the item is available.protected void
checkInventoryAvailability(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Product product, @NonNull List<Product> products, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Checks the inventory of the cart item.protected void
checkInventoryAvailability(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Product product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected void
checkQuantityWithinThreshold(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem, Product product)
Checks if the quantity of the item fits within the threshold.com.broadleafcommerce.cart.client.domain.Cart
createCart(@NonNull CartCreationRequest cartCreationRequest, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected com.broadleafcommerce.cart.client.domain.CartAlert
createCartAlert(String message)
protected com.broadleafcommerce.cart.client.domain.CartItem
createCartItem(@NonNull AddItemRequest addItemRequest)
Deprecated.in favor ofcreateCartItem(AddItemRequest, CurrencyUnit)
protected com.broadleafcommerce.cart.client.domain.CartItem
createCartItem(@NonNull AddItemRequest addItemRequest, javax.money.CurrencyUnit currencyUnit)
Creates aCartItem
based on the providedAddItemRequest
protected com.broadleafcommerce.cart.client.domain.Cart
createEmptyCart(com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected com.broadleafcommerce.cart.client.domain.Cart
createEmptyCart(com.broadleafcommerce.order.common.domain.CustomerRef customer, javax.money.CurrencyUnit currencyUnit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Creates and returns an empty, unsavedCart
with typical defaults.protected void
createFulfillmentGroupForItems(@NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @NonNull String fulfillmentType, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.protected void
createFulfillmentGroupForItems(@NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @NonNull String fulfillmentType, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem parentCartItem)
protected com.broadleafcommerce.cart.client.domain.Cart
createItemAndAddToCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull AddItemRequest addItemRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected com.broadleafcommerce.cart.client.domain.Cart
createItemAndAddToCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull AddItemRequest addItemRequest, javax.money.CurrencyUnit currencyUnit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Creates a new item and adds it to the providedCart
.protected BulkAddToCartResponse
createItemsAndAddToCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, Collection<AddItemRequest> addItemRequests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Creates new items and adds them to the providedCart
.protected void
defaultCartCurrency(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, javax.money.CurrencyUnit currencyUnit)
protected void
defaultCartCurrency(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.in favor ofdefaultCartCurrency(Cart, CurrencyUnit)
protected void
defaultCartLocale(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected String
determineDependentItemKey(@NonNull Product product, @NonNull com.broadleafcommerce.cart.client.domain.CartItem dependantCartItem)
Determines the item key for the dependent cart item.protected String
determineInventoryCheckStrategy(@NonNull Product product, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
protected boolean
doesCartContainCampaignForCode(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String code)
Determines whether theCart
contains aCampaignRef
that matches thecode
.protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
getAuthenticationUtils()
protected CartItemConfigurationService
getCartItemConfigurationService()
protected Map<String,com.broadleafcommerce.cart.client.domain.CartItem>
getCartItemIdsWithDependentItem(List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems)
protected CartItemMergingService<com.broadleafcommerce.cart.client.domain.CartItem>
getCartItemMergingService()
protected CartItemProductService
getCartItemProductService()
protected CartPricingService
getCartPricingService()
protected String
getCartTotalChangeMessage(javax.money.MonetaryAmount latestCartPrice)
protected javax.money.CurrencyUnit
getCurrencyUnit(PriceCartRequest priceCartRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Call utility method to determine currency.protected Supplier<com.broadleafcommerce.cart.client.domain.FulfillmentGroup>
getFulfillmentGroupById(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String fulfillmentGroupId)
Gets the fulfillment group by the provided ID.protected String
getMessage(@NonNull String errorMessage, Object... args)
protected org.springframework.context.MessageSource
getMessageSource()
protected CartOperationServiceOfferUtils
getOfferUtils()
protected PaymentProvider<PaymentSummary>
getPaymentProvider()
protected String
getPricingChangeMessage(javax.money.MonetaryAmount oldCartPrice, javax.money.MonetaryAmount latestCartPrice)
protected Object
getProductType(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
protected CartOperationServiceProperties
getProperties()
protected CartOperationServiceProviders
getProviders()
protected List<com.broadleafcommerce.order.common.domain.Adjustment>
getRelatedAdjustments(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String code)
protected Map<String,Integer>
getRequestedQuantitiesPerSku(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Product product)
Deprecated.protected Map<String,Integer>
getRequestedQuantitiesPerSku(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Product product, @NonNull List<Product> products)
protected com.broadleafcommerce.cart.client.domain.CartItem
getRequiredCartItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String cartItemId)
Gets a cart item from the cart by its ID.protected StaleCartItemsService
getStaleCartItemsService()
protected StaleCartPricingResultHolder
getStaleCartPricingResultHolder()
protected TaxService
getTaxService()
protected com.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
protected void
invalidateFulfillmentGroupOverride(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
protected boolean
isPaymentReallocationRequired(javax.money.MonetaryAmount previousCartTotal, javax.money.MonetaryAmount newCartTotal)
protected BulkAddToCartResponse
newBulkAddToCartResponse()
Instantiates a newBulkAddToCartResponse
using theTypeFactory
.protected com.broadleafcommerce.cart.client.domain.Cart
newCart()
Uses theTypeFactory
to create a newCart
object.protected CartCreationRequest
newCartCreationRequest()
protected com.broadleafcommerce.cart.client.domain.CartPricing
newCartPricing()
Uses theTypeFactory
to create a newCartPricing
object.protected String
newCartStatus(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Determines what status should be used when creating new carts.protected boolean
populateCartItemUpdates(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull UpdateItemRequest request)
Takes the changes from theUpdateItemRequest
and populates them onto theCartItem
.protected boolean
populateCartUpdatesFromUpdateItemRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull UpdateItemRequest request)
Takes the changes from theUpdateItemRequest
and populates them onto theCart
.protected com.broadleafcommerce.cart.client.domain.CartItem
populateFromRequest(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull AddItemRequest addItemRequest)
Deprecated.protected com.broadleafcommerce.cart.client.domain.CartItem
populateFromRequest(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull AddItemRequest addItemRequest, javax.money.CurrencyUnit currencyUnit)
Populates the cart item fields based on the request.com.broadleafcommerce.cart.client.domain.Cart
priceCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest, boolean saveCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Prices cart, processes free gift offers, and saves cart with the providedPriceCartRequest
ifsaveCart
is true.com.broadleafcommerce.cart.client.domain.Cart
priceCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Prices and saves the cart with the providedPriceCartRequest
.com.broadleafcommerce.cart.client.domain.Cart
priceCartWithCatalogPriceUpdates(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Reprice the cart, including applying the latest catalog-based prices for each of its itemsprotected List<com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem>
processExistingFreeGiftItems(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> updatedCartItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Updates existing free gift items quantities and remove existing free gift items if necessary, and then return a list ofFreeGiftItems
to add to cart.protected void
processFreeGiftItemsForRemoval(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> cartItemsBeingRemoved)
Processes free gift items wheneverCartItems
are being removed.protected void
processFreeGiftOffers(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Processes all free gift offers stored inCart.getInternalAttributes()
.protected void
reallocateCartTotalAmongstPayments(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull javax.money.MonetaryAmount newCartTotal, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected void
reallocateCartTotalAmongstPayments(@NonNull List<PaymentSummary> paymentSummaries, @NonNull javax.money.MonetaryAmount cartTotal, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Hook point to automatically reallocate the cart total amongst the cart's payments.com.broadleafcommerce.cart.client.domain.Cart
recalculateTaxesForCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimated, boolean actual, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Recalculates the taxes for the providedCart
.protected void
removeAssociatedFreeGiftItems(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> cartItemsBeingRemoved)
Removes the associated free gift item if the offer qualifier item is removed.com.broadleafcommerce.cart.client.domain.Cart
removeAttributeFromCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String key, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Removes an attribute to the providedCart
.com.broadleafcommerce.cart.client.domain.Cart
removeCartItems(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, Collection<String> cartItemIds, boolean allowPriceCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Remove items from the cart.protected void
removeExistingFreeGiftItemsFromCart(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> existingFreeGiftItemsToRemove, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Remove existing free giftCartItems
from cart.protected com.broadleafcommerce.cart.client.domain.Cart
removeFulfillmentItemsWithoutCartItems(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
com.broadleafcommerce.cart.client.domain.Cart
removeItemFromCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String cartItemId, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Removes a single item from the providedCart
matching the provided cart item ID.protected void
removeItemsFromFulfillmentGroup(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems)
com.broadleafcommerce.cart.client.domain.Cart
removeManyItemsFromCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, Collection<String> cartItemIds, boolean price, boolean updateCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Removes one or more items from the providedCart
matching the provided cart item IDs.com.broadleafcommerce.cart.client.domain.Cart
removeOfferAndCampaignCodesFromCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, List<String> codes, boolean allowPriceCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Removes the provided offer and campaign codes from the cart and then updates the cart.com.broadleafcommerce.cart.client.domain.Cart
removeOfferCodeFromCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String offerCode, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Removes an offer code from the providedCart
, if it exists.protected com.broadleafcommerce.cart.client.domain.Cart
removeStaleCartItem(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected Optional<com.broadleafcommerce.cart.client.domain.Cart>
repriceCartIfPricingIsStale(Optional<com.broadleafcommerce.cart.client.domain.Cart> optionalCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Called during cart resolution to check if the catalog prices on the cart are stale, and if so, updates those prices and resets the time since they were last changed.protected void
resetFulfillmentGroupReferenceNumbers(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
protected String
resolveDefaultFulfillmentType(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Determines the defaultFulfillmentType
for the providedCartItem
protected String
resolveTaxAddressSource(String fulfillmentType)
Determines the tax address source that should be used forFulfillmentGroup.getTaxAddressSource()
for the given fulfillment type.Optional<com.broadleafcommerce.cart.client.domain.Cart>
retrieveCartByCartId(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the cart for the provided id.protected Optional<com.broadleafcommerce.cart.client.domain.Cart>
retrieveCartByCartIdWithStatus(@NonNull String cartId, com.broadleafcommerce.cart.client.domain.enums.CartStatus status, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Optional<com.broadleafcommerce.cart.client.domain.Cart>
retrieveCsrCartByCartId(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the cart for the provided id, as long as it is CSR-owned.Optional<com.broadleafcommerce.cart.client.domain.Cart>
retrieveCsrOwnedCartByCustomerIdAndApplicationId(@NonNull String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the CSR-owned cart for the provided customer.Optional<com.broadleafcommerce.cart.client.domain.Cart>
retrieveCustomerCartByStatus(String customerId, String status, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieves a cart with the provided customer ID and status, if it existsOptional<com.broadleafcommerce.cart.client.domain.Cart>
retrieveInProcessCartByCartId(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the cart for the provided id, as long as it is in-process.Optional<com.broadleafcommerce.cart.client.domain.Cart>
retrieveInProcessCartByCustomerIdAndApplicationId(@NonNull String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the in-process cart for the provided customer.Optional<com.broadleafcommerce.cart.client.domain.Cart>
retrieveTestCartByCartId(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the cart for the provided id, as long as it is a test cart.protected com.broadleafcommerce.cart.client.domain.Cart
saveCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Helper method to encapsulate saving an existing Cart.void
setOfferUtils(CartOperationServiceOfferUtils offerUtils)
void
setPaymentProvider(PaymentProvider<PaymentSummary> paymentProvider)
void
setStaleCartItemsService(StaleCartItemsService staleCartItemsService)
com.broadleafcommerce.cart.client.domain.Cart
updateAsNamedCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String name, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Updates the providedCart
with theDefaultCartStatuses.NAMED
.com.broadleafcommerce.cart.client.domain.Cart
updateCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean allowPriceCart, boolean wasCartModified, boolean invalidatePrices, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Updates the providedCart
based on the provided flags.protected com.broadleafcommerce.cart.client.domain.Cart
updateCartAttributes(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull List<AddItemRequest> successfulAddItemRequests)
Update cart attributes based on the successfulAddItemRequests
com.broadleafcommerce.cart.client.domain.Cart
updateCartContactInfo(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull ContactInfoRequest contactInfoRequest, boolean allowPriceCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Update contact information to allow business users to contact the customer if needed.com.broadleafcommerce.cart.client.domain.Cart
updateCartItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull UpdateItemRequest updateItemRequest, boolean allowPriceCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Update the cart item.com.broadleafcommerce.cart.client.domain.Cart
updateContactInfoInCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull ContactInfoRequest contactInfoRequest, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Updates the contact info for the providedCart
.protected void
updateExistingFreeGiftItem(com.broadleafcommerce.cart.client.domain.CartItem existingFreeGiftItem, com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem freeGift, List<com.broadleafcommerce.cart.client.domain.CartItem> updatedCartItems)
Updates existing free giftCartItem
with the latest details from the givenFreeGiftItem
and update itsAdjustment
.com.broadleafcommerce.cart.client.domain.Cart
updateFulfillmentGroup(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String fulfillmentGroupId, @NonNull UpdateFulfillmentGroupRequest fulfillmentGroupRequest, boolean allowPriceCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Update the fulfillment group.com.broadleafcommerce.cart.client.domain.Cart
updateFulfillmentGroupInCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String referenceNumber, @NonNull UpdateFulfillmentGroupRequest updateFulfillmentGroupRequest, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Updates an existingFulfillmentGroup
for the providedCart
.protected void
updateFulfillmentItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Updates theFulfillmentItem
corresponding to theCartItem
, keeping them in sync.com.broadleafcommerce.cart.client.domain.Cart
updateItemInCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull UpdateItemRequest updateItemRequest, boolean price, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Updates a single item in the providedCart
based on the providedUpdateItemRequest
.protected void
validateCartItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Product product, @NonNull List<Product> products, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Validates that theCartItem
includes enough information to correctly represent the product or one of the product's variants.protected void
validateCartItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Product product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected void
validateCartItemAfterUpdate(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Product product, @NonNull List<Product> products, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected void
validateCartItemAfterUpdate(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Product product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected void
validateCartItemBeforeUpdate(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull UpdateItemRequest updateItemRequest)
Validates theCartItem
being updated againstUpdateItemRequest
before the actual cart item update.protected void
validateFreeGiftItemForUpdate(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull UpdateItemRequest updateItemRequest)
If the givenCartItem
is a free gift item, validates that its quantity is not being changed.protected void
verifySkuAvailability(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Product product, @NonNull List<Product> products, @NonNull Map<String,Boolean> availabilityMap)
protected void
verifySkuAvailability(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Product product, @NonNull Map<String,Boolean> availabilityMap)
Deprecated.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.cartoperation.service.CartOperationService
priceCart, priceCart, removeManyItemsFromCart
-
-
-
-
Constructor Detail
-
DefaultCartOperationService
public DefaultCartOperationService(CartOperationServiceProviders providers, CartPricingService cartPricingService, CartItemConfigurationService cartItemConfigurationService, CartItemProductService cartItemProductService, com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartOperationServiceProperties properties, CartItemMergingService<com.broadleafcommerce.cart.client.domain.CartItem> cartItemMergingService, org.springframework.context.MessageSource messageSource, TaxService taxService, StaleCartPricingResultHolder staleCartPricingResultHolder)
-
-
Method Detail
-
retrieveCartByCartId
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartByCartId(@NonNull @NonNull String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Retrieve the cart for the provided id.- Specified by:
retrieveCartByCartId
in interfaceCartOperationService
- Parameters:
cartId
- The id of the cart on which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart for the provided id.
-
retrieveCustomerCartByStatus
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCustomerCartByStatus(String customerId, String status, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Retrieves a cart with the provided customer ID and status, if it exists- Specified by:
retrieveCustomerCartByStatus
in interfaceCartOperationService
- Parameters:
customerId
- the customer IDstatus
- the statuscontextInfo
- the context info- Returns:
- the cart, if it exists
-
createCart
public com.broadleafcommerce.cart.client.domain.Cart createCart(@NonNull @NonNull CartCreationRequest cartCreationRequest, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Creates a new, in-progressCart
for the providedCartCreationRequest
andCustomerRef
. TheCartCreationRequest
must containFor guest customers, this will create a new guest cart
- Specified by:
createCart
in interfaceCartOperationService
- Parameters:
cartCreationRequest
- the cart creation requestcustomer
- the customercontextInfo
- the context info- Returns:
- the newly created cart
-
processFreeGiftOffers
protected void processFreeGiftOffers(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Processes all free gift offers stored inCart.getInternalAttributes()
. This will automatically add free gift cart items to cart, update existing free gift items, and remove existing free gift items, if necessary.- Parameters:
cart
- theCart
to process the free gift offers forcontextInfo
- the contextInfo for the request
-
processExistingFreeGiftItems
protected List<com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem> processExistingFreeGiftItems(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> updatedCartItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Updates existing free gift items quantities and remove existing free gift items if necessary, and then return a list ofFreeGiftItems
to add to cart.- Parameters:
cart
- theCart
to process existing free gift items forupdatedCartItems
- a list ofCartItems
whose quantities were updatedcontextInfo
- the contextInfo for the request- Returns:
- a list of
FreeGiftItems
to add to cart
-
updateExistingFreeGiftItem
protected void updateExistingFreeGiftItem(com.broadleafcommerce.cart.client.domain.CartItem existingFreeGiftItem, com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem freeGift, List<com.broadleafcommerce.cart.client.domain.CartItem> updatedCartItems)
Updates existing free giftCartItem
with the latest details from the givenFreeGiftItem
and update itsAdjustment
.- Parameters:
existingFreeGiftItem
- the existing free giftCartItem
to update theFreeGiftItem
details forfreeGift
- theFreeGiftItem
to update the existing free giftCartItem
withupdatedCartItems
- a list ofCartItems
whose quantities were updated, used to ensure theFulfillmentItems
are updated as well
-
buildAdjustment
protected com.broadleafcommerce.order.common.domain.Adjustment buildAdjustment(com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment offerAdjustment)
Builds anAdjustment
based on the givenAdjustment
.- Parameters:
offerAdjustment
- theAdjustment
to build it from- Returns:
- an
Adjustment
based on the givenAdjustment
-
buildOfferItemDetails
protected com.broadleafcommerce.order.common.domain.OfferItemDetail buildOfferItemDetails(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferItemDetail offerItemDetail)
Builds anOfferItemDetail
from the givenOfferItemDetail
.- Parameters:
offerItemDetail
- theOfferItemDetail
to build theOfferItemDetail
from- Returns:
- an
OfferItemDetail
from the givenOfferItemDetail
-
addFreeGiftItemsToCart
protected void addFreeGiftItemsToCart(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem> freeGiftItemsToAdd, List<com.broadleafcommerce.cart.client.domain.CartItem> updatedCartItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds the list ofFreeGiftItems
to cart, and then adds the ids of those added free gift cart items to the qualifier cart items attributes.- Parameters:
cart
- theCart
to add theFreeGiftItems
tofreeGiftItemsToAdd
- a list ofFreeGiftItems
to addupdatedCartItems
- a list ofCartItems
whose attributes were updated
-
removeExistingFreeGiftItemsFromCart
protected void removeExistingFreeGiftItemsFromCart(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> existingFreeGiftItemsToRemove, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Remove existing free giftCartItems
from cart.Before removing existing free gift
CartItems
, this removes theCartItemAttributeConstants.Internal.IS_FREE_GIFT_ITEM
attribute to ensure that the free gift offer is not added to the offer ignore list inaddRemovedFreeGiftOfferToIgnoreList(Cart, List)
.- Parameters:
cart
- theCart
to remove the existing free gift items fromexistingFreeGiftItemsToRemove
- the existing free giftCartItems
to removecontextInfo
- the contextInfo for the request- See Also:
CartOperationService.removeManyItemsFromCart(Cart, Collection, boolean, ContextInfo)
,processFreeGiftItemsForRemoval(Cart, List)
-
buildAddItemRequest
protected AddItemRequest buildAddItemRequest(com.broadleafcommerce.promotion.offer.client.web.context.info.FreeGiftItem freeGiftItem)
Builds anAddItemRequest
from the givenFreeGiftItem
.- Parameters:
freeGiftItem
-FreeGiftItem
to build theAddItemRequest
for- Returns:
- the
AddItemRequest
for the givenFreeGiftItem
-
updateCart
public com.broadleafcommerce.cart.client.domain.Cart updateCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean allowPriceCart, boolean wasCartModified, boolean invalidatePrices, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Updates the providedCart
based on the provided flags.
If the cart was not modified (wasCartModified
), this will price and update the cart when the cart is not already priced (Cart.isPriced()
), regardless ofinvalidatePrices
. If the cart was not modified and the cart is already priced, this does nothing.
If the cart was modified, the cart will be priced if allowed (allowPriceCart
) and if not already already priced or if prices should be invalidated.
Note: It is intentional that no overloaded methods are provided with default values for these parameters. Callers must consider carefully whether their operation modifies the cart or requires price invalidation.- Specified by:
updateCart
in interfaceCartOperationService
- Parameters:
cart
- the cart to be updatedallowPriceCart
- whether the cart may be pricedwasCartModified
- whether the cart was actually modified by the callerinvalidatePrices
- whether to invalidate prices on the cart if changes were made- Returns:
- synced version of the cart with the cart service
-
updateAsNamedCart
public com.broadleafcommerce.cart.client.domain.Cart updateAsNamedCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String name, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Updates the providedCart
with theDefaultCartStatuses.NAMED
. This method is often used when transferring or creating new carts for a registered customer who already has an in-progress cart.- Specified by:
updateAsNamedCart
in interfaceCartOperationService
- Parameters:
cart
- the cart to updatename
- the name for the cartcontextInfo
- the context info- Returns:
- the newly named cart
-
addItemToCart
public com.broadleafcommerce.cart.client.domain.Cart addItemToCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull AddItemRequest addItemRequest, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Adds a single item to the providedCart
based on the providedAddItemRequest
.- Specified by:
addItemToCart
in interfaceCartOperationService
- Parameters:
cart
- the cartaddItemRequest
- the request to add an itemprice
- whether or not to re-price the cartcontextInfo
- the context info- Returns:
- the cart with item added
-
updateItemInCart
public com.broadleafcommerce.cart.client.domain.Cart updateItemInCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull UpdateItemRequest updateItemRequest, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Updates a single item in the providedCart
based on the providedUpdateItemRequest
.- Specified by:
updateItemInCart
in interfaceCartOperationService
- Parameters:
cart
- the cartupdateItemRequest
- the request to update an itemprice
- whether or not to re-price the cartcontextInfo
- the context info- Returns:
- the cart with item updated
-
removeStaleCartItem
protected com.broadleafcommerce.cart.client.domain.Cart removeStaleCartItem(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
removeItemFromCart
public com.broadleafcommerce.cart.client.domain.Cart removeItemFromCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String cartItemId, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Removes a single item from the providedCart
matching the provided cart item ID.- Specified by:
removeItemFromCart
in interfaceCartOperationService
- Parameters:
cart
- the cartcartItemId
- the cart item IDprice
- whether or not to re-price the cartcontextInfo
- the context info- Returns:
- the cart without the provided item
-
addManyItemsToCart
public BulkAddToCartResponse addManyItemsToCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Collection<AddItemRequest> addItemRequests, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Adds one or more items to the providedCart
.- Specified by:
addManyItemsToCart
in interfaceCartOperationService
- Parameters:
cart
- the cartaddItemRequests
- the add item requestsprice
- whether or not to re-price the cartcontextInfo
- the context info- Returns:
- a response with the cart and any item failures
-
removeManyItemsFromCart
public com.broadleafcommerce.cart.client.domain.Cart removeManyItemsFromCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, Collection<String> cartItemIds, boolean price, boolean updateCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Removes one or more items from the providedCart
matching the provided cart item IDs.- Specified by:
removeManyItemsFromCart
in interfaceCartOperationService
- Parameters:
cart
- the cartcartItemIds
- the cart item IDsprice
- whether or not to re-price the cartupdateCart
- whether or not to updateCart
pricing and save the cart after the removalcontextInfo
- the context info- Returns:
- the cart without the provided item
-
processFreeGiftItemsForRemoval
protected void processFreeGiftItemsForRemoval(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> cartItemsBeingRemoved)
Processes free gift items wheneverCartItems
are being removed.- Parameters:
cart
- theCart
the items are being removed fromcartItemsBeingRemoved
- the list ofCartItems
being removed from cart
-
addRemovedFreeGiftOfferToIgnoreList
protected void addRemovedFreeGiftOfferToIgnoreList(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> cartItemsBeingRemoved)
Adds the offer id toCart's
ignore list inCart.getInternalAttributes()
whenever a free gift item is removed, so that the free gift item will not be added again.- Parameters:
cart
- theCart
to add the offer id ignore list tocartItemsBeingRemoved
- the list ofCartItems
being removed from cart- See Also:
CartAttributeConstants.Internal.OFFER_IDS_TO_IGNORE
-
removeAssociatedFreeGiftItems
protected void removeAssociatedFreeGiftItems(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> cartItemsBeingRemoved)
Removes the associated free gift item if the offer qualifier item is removed.- Parameters:
cart
- theCart
to remove the free gift item fromcartItemsBeingRemoved
- the list ofCartItems
being removed from cart
-
addOfferCodeToCart
public AddCodeToCartResponse addOfferCodeToCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull AddCodeRequest addOfferCodeRequest, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Adds an offer code to the providedCart
.- Determine if the code is valid as a campaign tracking code
- If so, add it to the cart as a
CampaignRef
- Determine if the code is valid as a shared code
- If so, add it to the cart
- Specified by:
addOfferCodeToCart
in interfaceCartOperationService
- Parameters:
cart
- the cartaddOfferCodeRequest
- the add offer code requestprice
- whether or not to re-price the cartcontextInfo
- the context info- Returns:
- An AddCodeToCartResponse describing the results of adding the offer code to the cart
-
buildAddCodeToCartResponse
protected AddCodeToCartResponse buildAddCodeToCartResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String code, boolean cartWasRepriced)
Builds anAddCodeToCartResponse
based on the provided cart, code, & whether or not the cart was repriced- Parameters:
cart
- The updatedCart
, including the code and applicable adjustments (discounts).code
- The offer code that was added to the cartcartWasRepriced
- Whether or not the cart was repriced after the code was added- Returns:
- An AddCodeToCartResponse describing the results of adding the offer code to the cart
-
getRelatedAdjustments
protected List<com.broadleafcommerce.order.common.domain.Adjustment> getRelatedAdjustments(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String code)
-
removeOfferCodeFromCart
public com.broadleafcommerce.cart.client.domain.Cart removeOfferCodeFromCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String offerCode, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Removes an offer code from the providedCart
, if it exists.- Determine if the code exists as a tracking code on the cart
- If so, remove the corresponding
CampaignRef
- Determine if the offer code exists on the cart
- If so, remove it
- Specified by:
removeOfferCodeFromCart
in interfaceCartOperationService
- Parameters:
cart
- cart cartofferCode
- the offer code to removeprice
- whether or not to re-price the cartcontextInfo
- the context info- Returns:
- the cart without the offer code
-
removeOfferAndCampaignCodesFromCart
public com.broadleafcommerce.cart.client.domain.Cart removeOfferAndCampaignCodesFromCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, List<String> codes, boolean allowPriceCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Removes the provided offer and campaign codes from the cart and then updates the cart.- Specified by:
removeOfferAndCampaignCodesFromCart
in interfaceCartOperationService
- Parameters:
cart
- The id of the cart on which to perform the operation.codes
- The codes to remove from the cart.allowPriceCart
- Whether to allow the cart to be priced after updatingcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart with the codes removed.
-
addAttributeToCart
public com.broadleafcommerce.cart.client.domain.Cart addAttributeToCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull AddAttributeRequest addAttributeRequest, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Adds an attribute to the providedCart
.- Specified by:
addAttributeToCart
in interfaceCartOperationService
- Parameters:
cart
- the cartaddAttributeRequest
- the add attribute requestprice
- whether to allow the cart to be priced after updatingcontextInfo
- the context info- Returns:
- the cart with the attribute added
-
removeAttributeFromCart
public com.broadleafcommerce.cart.client.domain.Cart removeAttributeFromCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String key, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Removes an attribute to the providedCart
.- Specified by:
removeAttributeFromCart
in interfaceCartOperationService
- Parameters:
cart
- the cartkey
- the attribute keyprice
- whether to allow the cart to be priced after updatingcontextInfo
- the context info- Returns:
- the cart without the attribute
-
updateContactInfoInCart
public com.broadleafcommerce.cart.client.domain.Cart updateContactInfoInCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull ContactInfoRequest contactInfoRequest, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Updates the contact info for the providedCart
.- Specified by:
updateContactInfoInCart
in interfaceCartOperationService
- Parameters:
cart
- the cartcontactInfoRequest
- the contact info requestprice
- whether to allow the cart to be priced after updatingcontextInfo
- the context info- Returns:
- the cart with contact info updated
-
updateFulfillmentGroupInCart
public com.broadleafcommerce.cart.client.domain.Cart updateFulfillmentGroupInCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String referenceNumber, @NonNull @NonNull UpdateFulfillmentGroupRequest updateFulfillmentGroupRequest, boolean price, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Updates an existingFulfillmentGroup
for the providedCart
.- Specified by:
updateFulfillmentGroupInCart
in interfaceCartOperationService
- Parameters:
cart
- the cartreferenceNumber
- the reference number of the fulfillment group to updateupdateFulfillmentGroupRequest
- the fulfillment group update requestprice
- whether to allow the cart to be priced after updatingcontextInfo
- the context info- Returns:
- the cart with an updated fulfillment group
-
priceCart
public com.broadleafcommerce.cart.client.domain.Cart priceCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable PriceCartRequest priceCartRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Prices and saves the cart with the providedPriceCartRequest
.- Specified by:
priceCart
in interfaceCartOperationService
- Parameters:
cart
- the cartpriceCartRequest
- the price cart requestcontextInfo
- the context info- Returns:
- the priced cart
-
priceCart
public com.broadleafcommerce.cart.client.domain.Cart priceCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable PriceCartRequest priceCartRequest, boolean saveCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Prices cart, processes free gift offers, and saves cart with the providedPriceCartRequest
ifsaveCart
is true.- Specified by:
priceCart
in interfaceCartOperationService
- Parameters:
cart
- the cartpriceCartRequest
- the price cart requestsaveCart
- determines whether to save cart after pricingcontextInfo
- the context info- Returns:
- the priced cart
-
isPaymentReallocationRequired
protected boolean isPaymentReallocationRequired(@Nullable javax.money.MonetaryAmount previousCartTotal, @Nullable javax.money.MonetaryAmount newCartTotal)
-
reallocateCartTotalAmongstPayments
protected void reallocateCartTotalAmongstPayments(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull javax.money.MonetaryAmount newCartTotal, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
allocateCartTotalToPayment
protected PaymentSummary allocateCartTotalToPayment(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull javax.money.MonetaryAmount cartTotal, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Hook point to automatically reallocate the cart total to the cart's single payment. Note: if a payment makes use of a single-use token and a successful transaction has already been executed, then the amount cannot be changed. In that case, the payment will need to be redefined.- Parameters:
paymentSummary
- A summary of the cart's single paymentcartTotal
- The total price of the cartcontextInfo
- the contextInfo for the request
-
reallocateCartTotalAmongstPayments
protected void reallocateCartTotalAmongstPayments(@NonNull @NonNull List<PaymentSummary> paymentSummaries, @NonNull @NonNull javax.money.MonetaryAmount cartTotal, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Hook point to automatically reallocate the cart total amongst the cart's payments. Note: if a payment makes use of a single-use token and a successful transaction has already been executed, then the amount cannot be changed. In that case, the payment will need to be redefined.- Parameters:
paymentSummaries
- Summaries of the cart's paymentscartTotal
- The total price of the cartcontextInfo
- the contextInfo for the request
-
priceCartWithCatalogPriceUpdates
public com.broadleafcommerce.cart.client.domain.Cart priceCartWithCatalogPriceUpdates(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Reprice the cart, including applying the latest catalog-based prices for each of its items- Specified by:
priceCartWithCatalogPriceUpdates
in interfaceCartOperationService
- Parameters:
cart
- The cart on which to perform the operation.contextInfo
- the context info- Returns:
- the priced cart
-
recalculateTaxesForCart
public com.broadleafcommerce.cart.client.domain.Cart recalculateTaxesForCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimated, boolean actual, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Recalculates the taxes for the providedCart
.- Specified by:
recalculateTaxesForCart
in interfaceCartOperationService
- Parameters:
cart
- the cartestimated
- whether to calculate estimated taxesactual
- whether to calculate actual taxescontextInfo
- the context info- Returns:
- the cart with taxes updated
-
getCurrencyUnit
protected javax.money.CurrencyUnit getCurrencyUnit(@Nullable PriceCartRequest priceCartRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Call utility method to determine currency.- Parameters:
priceCartRequest
- the price cart request to look for currencycontextInfo
- the context info to look for currency- Returns:
- the currency to be used for the request
-
saveCart
protected com.broadleafcommerce.cart.client.domain.Cart saveCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Helper method to encapsulate saving an existing Cart.- Parameters:
cart
- the cartcontextInfo
- the context info- Returns:
- the saved cart
-
removeFulfillmentItemsWithoutCartItems
protected com.broadleafcommerce.cart.client.domain.Cart removeFulfillmentItemsWithoutCartItems(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
-
createEmptyCart
protected com.broadleafcommerce.cart.client.domain.Cart createEmptyCart(@Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable javax.money.CurrencyUnit currencyUnit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Creates and returns an empty, unsavedCart
with typical defaults.- Parameters:
customer
- the customercurrencyUnit
- the currency for the cartcontextInfo
- the context info- Returns:
- the new empty cart
-
createEmptyCart
@Deprecated protected com.broadleafcommerce.cart.client.domain.Cart createEmptyCart(@Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Creates and returns an empty, unsavedCart
with typical defaults.- Parameters:
customer
- the customercontextInfo
- the context info- Returns:
- the new empty cart
-
defaultCartLocale
protected void defaultCartLocale(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
defaultCartCurrency
protected void defaultCartCurrency(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable javax.money.CurrencyUnit currencyUnit)
-
defaultCartCurrency
@Deprecated protected void defaultCartCurrency(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.in favor ofdefaultCartCurrency(Cart, CurrencyUnit)
-
newCart
protected com.broadleafcommerce.cart.client.domain.Cart newCart()
Uses theTypeFactory
to create a newCart
object.- Returns:
- the new cart
-
newCartPricing
protected com.broadleafcommerce.cart.client.domain.CartPricing newCartPricing()
Uses theTypeFactory
to create a newCartPricing
object.- Returns:
- the new cart pricing
-
newCartCreationRequest
protected CartCreationRequest newCartCreationRequest()
-
newCartStatus
protected String newCartStatus(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Determines what status should be used when creating new carts.- Parameters:
contextInfo
- the context info- Returns:
- the status to be used for a new cart
-
newBulkAddToCartResponse
protected BulkAddToCartResponse newBulkAddToCartResponse()
Instantiates a newBulkAddToCartResponse
using theTypeFactory
.- Returns:
- a new bulk add to cart response
-
createItemAndAddToCart
protected com.broadleafcommerce.cart.client.domain.Cart createItemAndAddToCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull AddItemRequest addItemRequest, @Nullable javax.money.CurrencyUnit currencyUnit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Creates a new item and adds it to the providedCart
.- Parameters:
cart
- the cartaddItemRequest
- the add item requestcurrencyUnit
- the currency for the item(s)contextInfo
- the context info
-
createItemAndAddToCart
@Deprecated protected com.broadleafcommerce.cart.client.domain.Cart createItemAndAddToCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull AddItemRequest addItemRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Creates a new item and adds it to the providedCart
.- Parameters:
cart
- the cartaddItemRequest
- the add item requestcontextInfo
- the context info
-
createItemsAndAddToCart
protected BulkAddToCartResponse createItemsAndAddToCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, Collection<AddItemRequest> addItemRequests, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Creates new items and adds them to the providedCart
.- Parameters:
cart
- the cartaddItemRequests
- the add item requestcontextInfo
- the context info
-
addUnassignedItemsToFulfillmentGroup
protected com.broadleafcommerce.cart.client.domain.Cart addUnassignedItemsToFulfillmentGroup(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
IdentifyCartItems
that have not been assigned to aFulfillmentGroup
& add them to the relevant FulfillmentGroup.If the fulfillment type is
FulfillmentType.VIRTUAL
,CartOperationServiceProperties.getDefaultVirtualFulfillmentOptionName()
will be used to identify the default fulfillment option.- Parameters:
cart
- The cart whose items may need to be assigned to a fulfillment group- Returns:
- The updated cart whose items are all assigned to fulfillment groups
-
updateCartAttributes
protected com.broadleafcommerce.cart.client.domain.Cart updateCartAttributes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull List<AddItemRequest> successfulAddItemRequests)
Update cart attributes based on the successfulAddItemRequests
- Parameters:
cart
- The cart that was added tosuccessfulAddItemRequests
- List of AddItemRequests that were successfully processed- Returns:
- The updated cart
-
updateFulfillmentItem
protected void updateFulfillmentItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Updates theFulfillmentItem
corresponding to theCartItem
, keeping them in sync.- Parameters:
cart
-Cart
to which the items belongcartItem
-CartItem
with updates to be carried over to aFulfillmentItem
-
populateCartItemUpdates
protected boolean populateCartItemUpdates(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull UpdateItemRequest request)
Takes the changes from theUpdateItemRequest
and populates them onto theCartItem
.- Parameters:
cartItem
- TheCartItem
to be updated with changes fromrequest
request
- TheUpdateItemRequest
with changes forcartItem
- Returns:
- Whether
cartItem
should be revalidated after updates are populated.
-
populateCartUpdatesFromUpdateItemRequest
protected boolean populateCartUpdatesFromUpdateItemRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull UpdateItemRequest request)
Takes the changes from theUpdateItemRequest
and populates them onto theCart
.- Parameters:
cart
- TheCart
to be updated with changes fromrequest
request
- TheUpdateItemRequest
with changes forcart
- Returns:
- Whether
CartItem
referenced inrequest
should be revalidated after updates are populated.
-
validateCartItemBeforeUpdate
protected void validateCartItemBeforeUpdate(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull UpdateItemRequest updateItemRequest)
Validates theCartItem
being updated againstUpdateItemRequest
before the actual cart item update.By default, the
CartItem
being updated is only being validated against free gift requirements.- Parameters:
cartItem
- theCartItem
being updatedupdateItemRequest
- theUpdateItemRequest
containing the details for the update
-
validateFreeGiftItemForUpdate
protected void validateFreeGiftItemForUpdate(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull UpdateItemRequest updateItemRequest)
If the givenCartItem
is a free gift item, validates that its quantity is not being changed.By default, the quantity of a free gift item can only be changed by the system. This is because free gift items have their own specific behaviors, and the details of free gift items should only be modified by the system internally.
- Parameters:
cartItem
- theCartItem
to validateupdateItemRequest
- theUpdateItemRequest
containing the details for the update
-
validateCartItemAfterUpdate
protected void validateCartItemAfterUpdate(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Product product, @NonNull @NonNull List<Product> products, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
validateCartItemAfterUpdate
@Deprecated protected void validateCartItemAfterUpdate(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Product product, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
invalidateFulfillmentGroupOverride
protected void invalidateFulfillmentGroupOverride(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
-
addCampaignForCodeIfExists
protected boolean addCampaignForCodeIfExists(String code, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds acode
to theCart
if it belongs to a campaign.- Parameters:
code
- Code to be added that might match a campaign.cart
- Cart to add thecode
to.contextInfo
- the context info- Returns:
- The
CampaignRef.getCampaignTrackingId()
for the added campaign.
-
addOfferCodeIfUsable
protected boolean addOfferCodeIfUsable(String code, boolean isForCampaign, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Adds thecode
toCart.getOfferCodes()
if it's usable.- Parameters:
code
- The code to be addedisForCampaign
- Whether the code was used to add aCampaignRef
to thecart
cart
- The cart to add thecode
to- Returns:
- Whether the code was added.
- Throws:
AddCodeException
- if the code cannot be added for any reason. This is usually because the code is invalid or has already been used the maximum number of times. Note that if the code matched aCampaignRef
, then no exception is thrown here even if the code is not usable for the purpose of adding anOfferRef
because it was still usable in a general sense to add the campaign.AddCodeException.getReasonType()
will typically match the code'sCodeUsabilityInfo.getCodeUsabilityType()
and can be used on the frontend to determine messaging.
-
buildCampaignRef
protected com.broadleafcommerce.order.common.domain.CampaignRef buildCampaignRef(String code, String trackingId)
-
doesCartContainCampaignForCode
protected final boolean doesCartContainCampaignForCode(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String code)
Determines whether theCart
contains aCampaignRef
that matches thecode
.- Parameters:
cart
- Cart with campaigns to match againstcode
- Code to match with- Returns:
- Whether the cart contains a campaign for the code
-
getMessage
protected String getMessage(@NonNull @NonNull String errorMessage, @Nullable Object... args)
-
getFulfillmentGroupById
protected Supplier<com.broadleafcommerce.cart.client.domain.FulfillmentGroup> getFulfillmentGroupById(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String fulfillmentGroupId)
Gets the fulfillment group by the provided ID. By default this will be the owning Cart'sID
and the index of the group inCart.getFulfillmentGroups()
. You can simply provide the index for the fulfillment group to perform the operation.Example: Cart has id "12345", so the first fulfillment group has id "12345-0". If you want to find the fulfillment group, you can provide "0" to this method along with the cart to get it.
- Parameters:
cart
- The cart on which to find the fulfillment groupfulfillmentGroupId
- The ID for the fulfillment group to find. Usually defaults to the index of the group inCart.getFulfillmentGroups()
.- Returns:
- The corresponding FulfillmentGroup for the given cart and relative number.
-
getRequiredCartItem
protected com.broadleafcommerce.cart.client.domain.CartItem getRequiredCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String cartItemId)
Gets a cart item from the cart by its ID. Throws an error if the item could not be found.- Parameters:
cart
- the cart to search the items ofcartItemId
- the item ID to look for- Returns:
- the item with the given cart ID
- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- when no item with the ID exists in the cart
-
buildCartItem
protected com.broadleafcommerce.cart.client.domain.CartItem buildCartItem(@NonNull @NonNull AddItemRequest addItemRequest, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable javax.money.CurrencyUnit currencyUnit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Populates a new cart item from theAddItemRequest
. This will populate info from theCatalogProvider
to ensure that all the important catalog info is present on the item and is correct. After that population, the cart item will be validated based on the product's included products and product options.- Parameters:
addItemRequest
- Request from which to populate newCartItems
.cart
- The cart of the newCartItems
currencyUnit
- the currency for the cart item(s)- Returns:
- Populated
CartItems
. - Throws:
CartItemValidationException
- Thrown if the cart item is misconfigured based on the related product's included products and product options.
-
buildCartItem
@Deprecated protected com.broadleafcommerce.cart.client.domain.CartItem buildCartItem(@NonNull @NonNull AddItemRequest addItemRequest, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Populates a new cart item from theAddItemRequest
. This will populate info from theCatalogProvider
to ensure that all the important catalog info is present on the item and is correct. After that population, the cart item will be validated based on the product's included products and product options.- Parameters:
addItemRequest
- Request from which to populate newCartItems
.cart
- The cart of the newCartItems
- Returns:
- Populated
CartItems
. - Throws:
CartItemValidationException
- Thrown if the cart item is misconfigured based on the related product's included products and product options.
-
buildCartItems
protected DefaultCartOperationService.BulkCartItemCreationResponse buildCartItems(@NonNull @NonNull Collection<AddItemRequest> addItemRequests, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable javax.money.CurrencyUnit currencyUnit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Populates new cart items from theAddItemRequests
. This will populate info from theCatalogProvider
to ensure that all the important catalog info is present on the item and is correct. After that population, the cart item will be validated based on the product's included products and product options.- Parameters:
addItemRequests
- Request from which to populate newCartItems
.cart
- The cart of the newCartItems
currencyUnit
- the currency for the cart items- Returns:
- Populated
CartItems
. - Throws:
CartItemValidationException
- Thrown if the cart item is misconfigured based on the related product's included products and product options.
-
buildCartItems
@Deprecated protected DefaultCartOperationService.BulkCartItemCreationResponse buildCartItems(@NonNull @NonNull Collection<AddItemRequest> addItemRequests, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Populates new cart items from theAddItemRequests
. This will populate info from theCatalogProvider
to ensure that all the important catalog info is present on the item and is correct. After that population, the cart item will be validated based on the product's included products and product options.- Parameters:
addItemRequests
- Request from which to populate newCartItems
.cart
- The cart of the newCartItems
- Returns:
- Populated
CartItems
. - Throws:
CartItemValidationException
- Thrown if the cart item is misconfigured based on the related product's included products and product options.
-
createCartItem
protected com.broadleafcommerce.cart.client.domain.CartItem createCartItem(@NonNull @NonNull AddItemRequest addItemRequest, @Nullable javax.money.CurrencyUnit currencyUnit)
Creates aCartItem
based on the providedAddItemRequest
- Parameters:
addItemRequest
- the request which contains the info to build a cart itemcurrencyUnit
- the currency for the cart item- Returns:
- the newly created cart item
-
createCartItem
@Deprecated protected com.broadleafcommerce.cart.client.domain.CartItem createCartItem(@NonNull @NonNull AddItemRequest addItemRequest)
Deprecated.in favor ofcreateCartItem(AddItemRequest, CurrencyUnit)
Creates aCartItem
based on the providedAddItemRequest
- Parameters:
addItemRequest
-- Returns:
-
populateFromRequest
protected com.broadleafcommerce.cart.client.domain.CartItem populateFromRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull AddItemRequest addItemRequest, @Nullable javax.money.CurrencyUnit currencyUnit)
Populates the cart item fields based on the request.- Parameters:
cartItem
- the cart item to populateaddItemRequest
- the request which contains the info to build a cart itemcurrencyUnit
- the currency for the cart item- Returns:
- the populated cart item
-
getProductType
@Nullable protected Object getProductType(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
-
populateFromRequest
@Deprecated protected com.broadleafcommerce.cart.client.domain.CartItem populateFromRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull AddItemRequest addItemRequest)
Deprecated.Populates the cart item fields based on the request.- Parameters:
cartItem
-addItemRequest
- the request which contains the info to build a cart item- Returns:
- the current cart
-
buildItemAttributeChoices
protected Map<String,com.broadleafcommerce.order.common.domain.AttributeChoiceValue> buildItemAttributeChoices(@NonNull @NonNull Map<String,String> requestItemAttributeChoices)
-
validateCartItem
protected void validateCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Product product, @NonNull @NonNull List<Product> products, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Validates that theCartItem
includes enough information to correctly represent the product or one of the product's variants.- Parameters:
cartItem
- The CartItem that is being validatedcart
- The CartItem's owning cartproduct
- The product that this CartItem is intended to representcontextInfo
- The contextInfo for the request
-
validateCartItem
@Deprecated protected void validateCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Product product, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
checkInventoryAvailability
protected void checkInventoryAvailability(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Product product, @NonNull @NonNull List<Product> products, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Checks the inventory of the cart item. First, it will check the catalog-based inventory details, and if it passes that check it will make a call to the inventory provider to check availability with the external inventory system.- Parameters:
cartItem
- The cart item whose inventory is being checkedcart
- The cart for thiscart item
product
- The product that this CartItem is intended to representproducts
- The list of products identified for this requestcontextInfo
- Context information about sandboxing and multitenant state
-
checkQuantityWithinThreshold
protected void checkQuantityWithinThreshold(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem, Product product)
Checks if the quantity of the item fits within the threshold.- Parameters:
cart
- The cart for thiscart item
cartItem
- The cart item whose quantity is being validatedproduct
- The product that this CartItem is intended to represent
-
checkInternalInventoryAvailability
protected void checkInternalInventoryAvailability(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Product product, @NonNull @NonNull List<Product> products)
Checks the inventory-related fields in the catalog data to determine whether or not the item is available.- Parameters:
cartItem
- The cart item whose inventory is being checkedproduct
- The product that this CartItem is intended to representproducts
- The list of products identified for this request
-
checkDependentItemInternalInventoryAvailability
protected void checkDependentItemInternalInventoryAvailability(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Product product, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem dependantCartItem, @NonNull @NonNull Product dependentProduct)
Checks the inventory-related fields in the catalog data to determine whether or not the dependent item is available.- Parameters:
cartItem
- The cart item whose inventory is being checkedproduct
- The product that this CartItem is intended to representdependantCartItem
- The dependent cart item whose inventory is being checkeddependentProduct
- The product that this dependent CartItem is intended to represent
-
determineDependentItemKey
protected String determineDependentItemKey(@NonNull @NonNull Product product, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem dependantCartItem)
Determines the item key for the dependent cart item.- Parameters:
product
- The product of the parent cart itemdependantCartItem
- The dependent cart item whose item key is being determined- Returns:
- the item key for the dependent item
-
checkInventoryAvailability
@Deprecated protected void checkInventoryAvailability(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Product product, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
getRequestedQuantitiesPerSku
protected Map<String,Integer> getRequestedQuantitiesPerSku(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Product product, @NonNull @NonNull List<Product> products)
-
getRequestedQuantitiesPerSku
@Deprecated protected Map<String,Integer> getRequestedQuantitiesPerSku(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Product product)
Deprecated.
-
determineInventoryCheckStrategy
protected String determineInventoryCheckStrategy(@NonNull @NonNull Product product, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
-
calculateItemsQuantityWithSameSku
protected int calculateItemsQuantityWithSameSku(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
-
calculateItemsQuantityWithSameSku
protected int calculateItemsQuantityWithSameSku(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, int parentItemQuantity)
-
calculateDependentItemsQuantityWithSameSku
protected int calculateDependentItemsQuantityWithSameSku(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, int parentQuantity)
-
verifySkuAvailability
protected void verifySkuAvailability(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Product product, @NonNull @NonNull List<Product> products, @NonNull @NonNull Map<String,Boolean> availabilityMap)
-
verifySkuAvailability
@Deprecated protected void verifySkuAvailability(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Product product, @NonNull @NonNull Map<String,Boolean> availabilityMap)
Deprecated.
-
buildInventoryUnavailableError
protected com.broadleafcommerce.cart.client.domain.ConfigError buildInventoryUnavailableError()
-
buildValidationFailure
protected AddItemFailure buildValidationFailure(@NonNull @NonNull AddItemRequest addItemRequest, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Builds anAddItemFailure
based on the providedAddItemRequest
&CartItem
representing an invalid add to cart request- Parameters:
addItemRequest
- The request that was used to build the CartItemcartItem
- The cart item that holds the validation failures- Returns:
- an AddItemFailure based on the provided AddItemRequest & CartItem
-
createFulfillmentGroupForItems
@Deprecated protected void createFulfillmentGroupForItems(@NonNull @NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @NonNull @NonNull String fulfillmentType, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.
-
createFulfillmentGroupForItems
protected void createFulfillmentGroupForItems(@NonNull @NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @NonNull @NonNull String fulfillmentType, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.cart.client.domain.CartItem parentCartItem)
-
resolveTaxAddressSource
protected String resolveTaxAddressSource(String fulfillmentType)
Determines the tax address source that should be used forFulfillmentGroup.getTaxAddressSource()
for the given fulfillment type.- Parameters:
fulfillmentType
- the fulfillment type from which to determine the tax address source- Returns:
- the tax address source that should be used
-
buildGroupReferenceNumber
protected String buildGroupReferenceNumber(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Builds aFulfillmentGroup.getReferenceNumber()
for a new group.- Parameters:
cart
- Cart that owns the group- Returns:
- The new reference number
-
buildGroupReferenceNumber
protected String buildGroupReferenceNumber(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String fulfillmentGroupId)
Builds aFulfillmentGroup.getReferenceNumber()
for the given cart and group ID.- Parameters:
cart
- Cart that owns the groupfulfillmentGroupId
- ID of the fulfillment group for which to build a reference number. Usually defaults to the index of the group inCart.getFulfillmentGroups()
.- Returns:
- The new reference number
-
addItemsToFulfillmentGroup
@Deprecated protected void addItemsToFulfillmentGroup(@NonNull @NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull @NonNull javax.money.CurrencyUnit expectedCurrency)
Deprecated.
-
addItemsToFulfillmentGroup
protected void addItemsToFulfillmentGroup(@NonNull @NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull @NonNull javax.money.CurrencyUnit expectedCurrency, @Nullable com.broadleafcommerce.cart.client.domain.CartItem parentCartItem)
-
addItemToFulfillmentGroup
@Deprecated protected void addItemToFulfillmentGroup(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Deprecated.
-
addItemToFulfillmentGroup
protected void addItemToFulfillmentGroup(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, Set<String> assignedCartItemIds, @Nullable com.broadleafcommerce.cart.client.domain.CartItem parentCartItem)
Assigns the cart item and its dependent cart items to the fulfillment group. If the fulfillment group doesn't exist it will be created. This method doesn't create the fulfillment item for theDefaultProductType.BUNDLE
items.- Parameters:
cart
- the cart whose items may need to be assigned to a fulfillment groupcartItem
- the cart item for which to create add the fulfillment itemassignedCartItemIds
- the set of the cart item ids for which the fulfillment item is already existsparentCartItem
- the parent cart item for the specified cart item. Usually, this is the item that has the dependent cart items
-
resolveDefaultFulfillmentType
@Nullable protected String resolveDefaultFulfillmentType(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Determines the defaultFulfillmentType
for the providedCartItem
- Parameters:
cartItem
- The cart item whose default fulfillment type must be determined- Returns:
- The default fulfillment type for the provided cart item
-
removeItemsFromFulfillmentGroup
protected void removeItemsFromFulfillmentGroup(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems)
-
getCartItemIdsWithDependentItem
protected Map<String,com.broadleafcommerce.cart.client.domain.CartItem> getCartItemIdsWithDependentItem(List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems)
-
resetFulfillmentGroupReferenceNumbers
protected void resetFulfillmentGroupReferenceNumbers(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
-
repriceCartIfPricingIsStale
protected Optional<com.broadleafcommerce.cart.client.domain.Cart> repriceCartIfPricingIsStale(Optional<com.broadleafcommerce.cart.client.domain.Cart> optionalCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Called during cart resolution to check if the catalog prices on the cart are stale, and if so, updates those prices and resets the time since they were last changed. Also sets the values for `staleCartPricingResultHolder` for checkout validation.- Parameters:
optionalCart
- Cart to be checked and pricedcontextInfo
- The contextInfo for the request- Returns:
-
getPricingChangeMessage
protected String getPricingChangeMessage(javax.money.MonetaryAmount oldCartPrice, javax.money.MonetaryAmount latestCartPrice)
-
getCartTotalChangeMessage
protected String getCartTotalChangeMessage(javax.money.MonetaryAmount latestCartPrice)
-
createCartAlert
protected com.broadleafcommerce.cart.client.domain.CartAlert createCartAlert(String message)
-
retrieveInProcessCartByCustomerIdAndApplicationId
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveInProcessCartByCustomerIdAndApplicationId(@NonNull @NonNull String customerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Retrieve the in-process cart for the provided customer.- Specified by:
retrieveInProcessCartByCustomerIdAndApplicationId
in interfaceCartOperationService
- Parameters:
customerId
- The id of the customer for which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The in-process cart for the provided customer.
-
retrieveInProcessCartByCartId
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveInProcessCartByCartId(@NonNull @NonNull String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Retrieve the cart for the provided id, as long as it is in-process.- Specified by:
retrieveInProcessCartByCartId
in interfaceCartOperationService
- Parameters:
cartId
- The id of the cart on which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The in-process cart for the provided id.
-
retrieveCsrCartByCartId
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCsrCartByCartId(@NonNull @NonNull String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Retrieve the cart for the provided id, as long as it is CSR-owned.- Specified by:
retrieveCsrCartByCartId
in interfaceCartOperationService
- Parameters:
cartId
- The id of the cart on which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The CSR-owned cart for the provided id.
-
retrieveTestCartByCartId
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveTestCartByCartId(@NonNull @NonNull String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Retrieve the cart for the provided id, as long as it is a test cart.- Specified by:
retrieveTestCartByCartId
in interfaceCartOperationService
- Parameters:
cartId
- The id of the cart on which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The test cart for the provided id.
-
retrieveCartByCartIdWithStatus
protected Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartByCartIdWithStatus(@NonNull @NonNull String cartId, com.broadleafcommerce.cart.client.domain.enums.CartStatus status, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
retrieveCsrOwnedCartByCustomerIdAndApplicationId
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCsrOwnedCartByCustomerIdAndApplicationId(@NonNull @NonNull String customerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Retrieve the CSR-owned cart for the provided customer.- Specified by:
retrieveCsrOwnedCartByCustomerIdAndApplicationId
in interfaceCartOperationService
- Parameters:
customerId
- The id of the customer for which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The CSR-owned cart for the provided customer.
-
addToCart
public com.broadleafcommerce.cart.client.domain.Cart addToCart(@NonNull @NonNull AddItemRequest addItemRequest, @Nullable com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customerRef, boolean allowPriceCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Add an item to the customer's current cart based on the provided untrusted information. By default, this includes the following steps:- Retrieve catalog information for the item
- Check inventory
- Create item and add it to the cart (un-priced)
- Price the item and cart, using offers and price lists (optional)
- Update the cart and it's items (optional)
- Specified by:
addToCart
in interfaceCartOperationService
- Parameters:
addItemRequest
- Add an item to the customer's current cart based on the provided untrusted information.cart
- The cart to be added to. If not provided, then a new cart will be produced.customerRef
- The cart's owning customer. Can be null if anonymous.allowPriceCart
- Whether to allow the cart to be priced after updatingcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart with the item added.
-
bulkAddToCart
public BulkAddToCartResponse bulkAddToCart(@NonNull @NonNull Collection<AddItemRequest> addItemRequests, @Nullable com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customerRef, boolean allowPriceCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Add a list of items to the customer's current cart based on the provided untrusted information. By default, this includes the following steps:- Retrieve catalog information for the items
- Check inventory
- Create item and add it to the cart (un-priced)
- Price the item and cart, using offers and price lists (optional)
- Update the cart and it's items (optional)
- Specified by:
bulkAddToCart
in interfaceCartOperationService
- Parameters:
addItemRequests
- Add a list of items to the customer's current cart based on the provided untrusted information.cart
- The id of the cart to be added to. If not provided, then a new cart will be produced.customerRef
- The cart's owning customer. Can be null if anonymous.allowPriceCart
- Whether the cart should be priced after updatingcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart with the items added.
-
updateCartItem
public com.broadleafcommerce.cart.client.domain.Cart updateCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull UpdateItemRequest updateItemRequest, boolean allowPriceCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Update the cart item.- Specified by:
updateCartItem
in interfaceCartOperationService
- Parameters:
cart
- The id of the cart on which to perform the operation.updateItemRequest
- The cart item to use to update the details of the current cart item.allowPriceCart
- Whether to allow the cart to be priced after updatingcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart with the updated item.
-
removeCartItems
public com.broadleafcommerce.cart.client.domain.Cart removeCartItems(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, Collection<String> cartItemIds, boolean allowPriceCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Remove items from the cart.- Specified by:
removeCartItems
in interfaceCartOperationService
- Parameters:
cart
- The id of the cart on which to perform the operation.cartItemIds
- The ids of the cart items on which to perform the operation.allowPriceCart
- Whether to allow the cart to be priced after updatingcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart with the item removed.
-
updateCartContactInfo
public com.broadleafcommerce.cart.client.domain.Cart updateCartContactInfo(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull ContactInfoRequest contactInfoRequest, boolean allowPriceCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Update contact information to allow business users to contact the customer if needed.- Specified by:
updateCartContactInfo
in interfaceCartOperationService
- Parameters:
cart
- The cart that hold the contact info.contactInfoRequest
- The contact info that is to be added to the cart.allowPriceCart
- Whether to allow the cart to be priced after updatingcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart with updated contact info.
-
addCodeToCart
public AddCodeToCartResponse addCodeToCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull AddCodeRequest codeRequest, boolean allowPriceCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
- Retrieve the cart
- Determine if the code is valid as a campaign tracking code
- If so, add it to the cart as a
CampaignRef
- Determine if the code is valid as a shared code
- If so, add it to the cart
- Update the cart
- Price the cart, using offers and price lists (optional)
- Update the cart and its items (optional)
- Specified by:
addCodeToCart
in interfaceCartOperationService
- Parameters:
cart
- The id of the cart on which to perform the operation.codeRequest
- The payload of the request to add a code to the cart.allowPriceCart
- Whether to allow the cart to be priced after updatingcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- An AddCodeToCartResponse describing the results of adding the offer code to the cart
-
updateFulfillmentGroup
public com.broadleafcommerce.cart.client.domain.Cart updateFulfillmentGroup(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String fulfillmentGroupId, @NonNull @NonNull UpdateFulfillmentGroupRequest fulfillmentGroupRequest, boolean allowPriceCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CartOperationService
Update the fulfillment group.- Specified by:
updateFulfillmentGroup
in interfaceCartOperationService
- Parameters:
cart
- The id of the cart on which to perform the operation.fulfillmentGroupId
- The id of the fulfillment group on which to perform the operation.fulfillmentGroupRequest
- The fulfillment group updates to be applied to the existing fulfillment group.allowPriceCart
- Whether to allow the cart to be priced after updatingcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The Cart for which the updated fulfillment group is a part.
-
getProviders
protected CartOperationServiceProviders getProviders()
-
getCartPricingService
protected CartPricingService getCartPricingService()
-
getCartItemConfigurationService
protected CartItemConfigurationService getCartItemConfigurationService()
-
getCartItemProductService
protected CartItemProductService getCartItemProductService()
-
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils()
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-
getProperties
protected CartOperationServiceProperties getProperties()
-
getCartItemMergingService
protected CartItemMergingService<com.broadleafcommerce.cart.client.domain.CartItem> getCartItemMergingService()
-
getMessageSource
protected org.springframework.context.MessageSource getMessageSource()
-
getTaxService
protected TaxService getTaxService()
-
getStaleCartPricingResultHolder
protected StaleCartPricingResultHolder getStaleCartPricingResultHolder()
-
getOfferUtils
protected CartOperationServiceOfferUtils getOfferUtils()
-
setOfferUtils
@Autowired public void setOfferUtils(CartOperationServiceOfferUtils offerUtils)
-
setStaleCartItemsService
@Autowired public void setStaleCartItemsService(StaleCartItemsService staleCartItemsService)
-
getStaleCartItemsService
protected StaleCartItemsService getStaleCartItemsService()
-
setPaymentProvider
@Autowired public void setPaymentProvider(PaymentProvider<PaymentSummary> paymentProvider)
-
getPaymentProvider
protected PaymentProvider<PaymentSummary> getPaymentProvider()
-
-