Class BroadleafCartController
- Author:
- Andre Azzolini (apazzolini)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Stringprotected booleanprotected static Stringprotected static Stringprotected static Stringprotected static Stringprotected static StringFields inherited from class org.broadleafcommerce.core.web.controller.cart.AbstractCartController
catalogService, dtoTranslationService, offerService, orderItemService, orderService, updateCartService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest) Takes in an item request, adds the item to the customer's current cart, and returns.addPromo(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String customerOffer) Attempts to add provided Offer to CartaddWithPriceOverride(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.AddToCartItem itemRequest) Deprecated.addWithPriceOverride(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest) Takes in an item request, adds the item to the customer's current cart, and returns.cart(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Renders the cart page.configure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Long productId) Takes a product id and builds out a dependant order item tree.empty(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) Cancels the current cart and redirects to the homepagehandleIllegalCartOpException(org.broadleafcommerce.core.order.service.exception.IllegalCartOperationException ex) protected booleanisCheckoutContext(jakarta.servlet.http.HttpServletRequest request) protected booleanisSafeToAdd(org.broadleafcommerce.core.order.service.call.ConfigurableOrderItemRequest itemRequest) protected booleanisUpdateRequest(jakarta.servlet.http.HttpServletRequest request) reconfigure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Long orderItemId) Takes an order item id and rebuilds the dependant order item tree with the current quantities and options set.remove(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest) Takes in an item request, updates the quantity of that item in the cart, and returnsremovePromo(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Long offerCodeId) Removes offer from cartprotected voidupdateAddRequestQuantities(org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest, Long originalOrderItemId) updateQuantity(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.AddToCartItem itemRequest) Deprecated.updateQuantity(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest) Takes in an item request and updates the quantity of that item in the cart.Methods inherited from class org.broadleafcommerce.common.web.controller.BroadleafAbstractController
addDeepLink, getContextPath, isAjaxRequest, jsonResponse
-
Field Details
-
cartView
-
checkoutView
-
cartPageRedirect
-
configureView
-
configurePageRedirect
-
ALL_PRODUCTS_ATTRIBUTE_NAME
-
automaticallyAddCompleteItems
@Value("${automatically.add.complete.items}") protected boolean automaticallyAddCompleteItems
-
-
Constructor Details
-
BroadleafCartController
public BroadleafCartController()
-
-
Method Details
-
cart
public String cart(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) throws org.broadleafcommerce.core.pricing.service.exception.PricingException Renders the cart page.If the method was invoked via an AJAX call, it will render the "ajax/cart" template. Otherwise, it will render the "cart" template.
Will reprice the order if the currency has been changed.
- Parameters:
request-response-model-- Throws:
org.broadleafcommerce.core.pricing.service.exception.PricingException
-
add
public String add(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest) throws IOException, org.broadleafcommerce.core.order.service.exception.AddToCartException, org.broadleafcommerce.core.pricing.service.exception.PricingException, NumberFormatException, org.broadleafcommerce.core.order.service.exception.RemoveFromCartException, IllegalArgumentException Takes in an item request, adds the item to the customer's current cart, and returns.If the method was invoked via an AJAX call, it will render the "ajax/cart" template. Otherwise, it will perform a 302 redirect to "/cart"
- Parameters:
request-response-model-itemRequest-- Throws:
IOExceptionorg.broadleafcommerce.core.order.service.exception.AddToCartExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingExceptionorg.broadleafcommerce.core.order.service.exception.RemoveFromCartExceptionNumberFormatExceptionIllegalArgumentException
-
updateAddRequestQuantities
protected void updateAddRequestQuantities(org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest, Long originalOrderItemId) -
isUpdateRequest
protected boolean isUpdateRequest(jakarta.servlet.http.HttpServletRequest request) -
addWithPriceOverride
public String addWithPriceOverride(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest) throws IOException, org.broadleafcommerce.core.order.service.exception.AddToCartException, org.broadleafcommerce.core.pricing.service.exception.PricingException Takes in an item request, adds the item to the customer's current cart, and returns.Calls the addWithOverrides method on the orderService which will honor the override prices on the OrderItemRequestDTO request object.
Implementors must secure this method to avoid accidentally exposing the ability for malicious clients to override prices by hacking the post parameters.
- Parameters:
request-response-model-itemRequest-- Throws:
IOExceptionorg.broadleafcommerce.core.order.service.exception.AddToCartExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingException
-
addWithPriceOverride
@Deprecated public String addWithPriceOverride(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.AddToCartItem itemRequest) throws IOException, org.broadleafcommerce.core.order.service.exception.AddToCartException, org.broadleafcommerce.core.pricing.service.exception.PricingException Deprecated.- Throws:
IOExceptionorg.broadleafcommerce.core.order.service.exception.AddToCartExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingException
-
configure
public String configure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Long productId) throws IOException, org.broadleafcommerce.core.order.service.exception.AddToCartException, org.broadleafcommerce.core.pricing.service.exception.PricingException, Exception Takes a product id and builds out a dependant order item tree. If it determines the order item is safe to add, it will proceed to calling the "add" method.If the method was invoked via an AJAX call, it will render the "ajax/configure" template. Otherwise, it will perform a 302 redirect to "/cart/configure"
In the case that an "add" happened it will render either the "ajax/cart" or perform a 302 redirect to "/cart"
- Parameters:
request-response-model-productId-- Throws:
IOExceptionorg.broadleafcommerce.core.order.service.exception.AddToCartExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingExceptionException
-
reconfigure
public String reconfigure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Long orderItemId) throws IOException, org.broadleafcommerce.core.order.service.exception.AddToCartException, org.broadleafcommerce.core.pricing.service.exception.PricingException, Exception Takes an order item id and rebuilds the dependant order item tree with the current quantities and options set.If the method was invoked via an AJAX call, it will render the "ajax/configure" template. Otherwise, it will perform a 302 redirect to "/cart/configure"
- Parameters:
request-response-model-orderItemId-- Throws:
IOExceptionorg.broadleafcommerce.core.order.service.exception.AddToCartExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingExceptionException
-
updateQuantity
public String updateQuantity(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest) throws IOException, org.broadleafcommerce.core.order.service.exception.UpdateCartException, org.broadleafcommerce.core.pricing.service.exception.PricingException, org.broadleafcommerce.core.order.service.exception.RemoveFromCartException Takes in an item request and updates the quantity of that item in the cart. If the quantity was passed in as 0, it will remove the item.If the method was invoked via an AJAX call, it will render the "ajax/cart" template. Otherwise, it will perform a 302 redirect to "/cart"
- Parameters:
request-response-model-itemRequest-- Throws:
IOExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingExceptionorg.broadleafcommerce.core.order.service.exception.UpdateCartExceptionorg.broadleafcommerce.core.order.service.exception.RemoveFromCartException
-
updateQuantity
@Deprecated public String updateQuantity(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.AddToCartItem itemRequest) throws IOException, org.broadleafcommerce.core.order.service.exception.UpdateCartException, org.broadleafcommerce.core.pricing.service.exception.PricingException, org.broadleafcommerce.core.order.service.exception.RemoveFromCartException Deprecated.- Throws:
IOExceptionorg.broadleafcommerce.core.order.service.exception.UpdateCartExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingExceptionorg.broadleafcommerce.core.order.service.exception.RemoveFromCartException
-
remove
public String remove(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO itemRequest) throws IOException, org.broadleafcommerce.core.pricing.service.exception.PricingException, org.broadleafcommerce.core.order.service.exception.RemoveFromCartException Takes in an item request, updates the quantity of that item in the cart, and returnsIf the method was invoked via an AJAX call, it will render the "ajax/cart" template. Otherwise, it will perform a 302 redirect to "/cart"
- Parameters:
request-response-model-itemRequest-- Throws:
IOExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingExceptionorg.broadleafcommerce.core.order.service.exception.RemoveFromCartException
-
empty
public String empty(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model) throws org.broadleafcommerce.core.pricing.service.exception.PricingException Cancels the current cart and redirects to the homepage- Parameters:
request-response-model-- Throws:
org.broadleafcommerce.core.pricing.service.exception.PricingException
-
addPromo
public String addPromo(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String customerOffer) throws IOException, org.broadleafcommerce.core.pricing.service.exception.PricingException Attempts to add provided Offer to Cart- Parameters:
request-response-model-customerOffer-- Returns:
- the return view
- Throws:
IOExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingExceptionorg.broadleafcommerce.core.offer.service.exception.OfferMaxUseExceededException
-
isCheckoutContext
protected boolean isCheckoutContext(jakarta.servlet.http.HttpServletRequest request) -
removePromo
public String removePromo(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Long offerCodeId) throws IOException, org.broadleafcommerce.core.pricing.service.exception.PricingException Removes offer from cart- Parameters:
request-response-model-- Returns:
- the return view
- Throws:
IOExceptionorg.broadleafcommerce.core.pricing.service.exception.PricingExceptionorg.broadleafcommerce.core.offer.service.exception.OfferMaxUseExceededException
-
getCartView
-
getCartPageRedirect
-
getConfigureView
-
getConfigurePageRedirect
-
getCheckoutView
-
handleIllegalCartOpException
-
isSafeToAdd
protected boolean isSafeToAdd(org.broadleafcommerce.core.order.service.call.ConfigurableOrderItemRequest itemRequest)
-