Class CartPageController


  • @Controller
    @Scope("tenant")
    @RequestMapping("/cart")
    public class CartPageController
    extends AbstractCartPageController
    Controller of the cart page and related cart operations, like remove or update cart.
    • Field Detail

      • SHOW_CHECKOUT_FLOWS_CONFIG_KEY

        public static final java.lang.String SHOW_CHECKOUT_FLOWS_CONFIG_KEY
        See Also:
        Constant Field Values
      • CART_CMS_PAGE_LABEL

        public static final java.lang.String CART_CMS_PAGE_LABEL
        See Also:
        Constant Field Values
      • CART_CHECKOUT_ERROR

        public static final java.lang.String CART_CHECKOUT_ERROR
        See Also:
        Constant Field Values
      • PAGE_TYPE_ATTRIBUTE

        public static final java.lang.String PAGE_TYPE_ATTRIBUTE
        See Also:
        Constant Field Values
      • CART_BREADCRUMB_KEY

        public static final java.lang.String CART_BREADCRUMB_KEY
        See Also:
        Constant Field Values
      • REDIRECT_TO_CART_URL

        public static final java.lang.String REDIRECT_TO_CART_URL
        See Also:
        Constant Field Values
      • TYPE_MISMATCH_ERROR_CODE

        public static final java.lang.String TYPE_MISMATCH_ERROR_CODE
        See Also:
        Constant Field Values
      • SUBSCRIPTION_PRODUCT_ERROR_REGEX

        public static final java.lang.String SUBSCRIPTION_PRODUCT_ERROR_REGEX
        See Also:
        Constant Field Values
      • SUBSCRIPTION_PRODUCT_BASKET_ERROR

        public static final java.lang.String SUBSCRIPTION_PRODUCT_BASKET_ERROR
        See Also:
        Constant Field Values
      • BASKET_REMOVE_MESSAGE

        public static final java.lang.String BASKET_REMOVE_MESSAGE
        See Also:
        Constant Field Values
      • BASKET_UPDATE_MESSAGE

        public static final java.lang.String BASKET_UPDATE_MESSAGE
        See Also:
        Constant Field Values
    • Constructor Detail

      • CartPageController

        public CartPageController()
    • Method Detail

      • showCart

        @RequestMapping(method=GET)
        public java.lang.String showCart​(org.springframework.ui.Model model)
                                  throws de.hybris.platform.cms2.exceptions.CMSItemNotFoundException
        Displays the cart page.
        Parameters:
        model - page model to be populated with information
        Returns:
        name of the view to be displayed
        Throws:
        de.hybris.platform.cms2.exceptions.CMSItemNotFoundException - if the CmsPage cannot be found, while populating the model with meta data or title information
      • cartCheck

        @RequestMapping(value="/checkout",
                        method=GET)
        public java.lang.String cartCheck​(org.springframework.ui.Model model,
                                          org.springframework.web.servlet.mvc.support.RedirectAttributes redirectModel)
        Handle the '/cart/checkout' request url. This method checks to see if the cart is valid before allowing the checkout to begin. Note that this method does not require the user to be authenticated and therefore allows us to validate that the cart is valid without first forcing the user to login. The cart will be checked again once the user has logged in.
        Parameters:
        model - the spring Model object. not used here, but included in the signature to allow overriding in subclasses.
        Returns:
        The page to redirect to
      • initCheck

        @RequestMapping(value="/checkout/select-flow",
                        method=GET)
        public java.lang.String initCheck​(org.springframework.ui.Model model,
                                          org.springframework.web.servlet.mvc.support.RedirectAttributes redirectModel,
                                          @RequestParam(value="flow",required=false)
                                          CheckoutFlowEnum checkoutFlow,
                                          @RequestParam(value="pci",required=false)
                                          CheckoutPciOptionEnum checkoutPci)
        Parameters:
        model - the Spring Model object. Included to allow subclass overriding.
        redirectModel - the RedirectAttributes object. Included to allow subclass overriding.
      • deleteCartBundle

        @RequestMapping(value="/delete",
                        method=POST)
        public java.lang.String deleteCartBundle​(@Valid
                                                 @Valid DeleteBundleForm form,
                                                 org.springframework.ui.Model model,
                                                 org.springframework.validation.BindingResult bindingResult,
                                                 org.springframework.web.servlet.mvc.support.RedirectAttributes redirectModel)
                                          throws de.hybris.platform.cms2.exceptions.CMSItemNotFoundException
        Deletes all cart entries corresponding to the bundle with the number given from the current cart.
        Parameters:
        form - bundle delete form, indicating the bundle No to be deleted
        model - page model to be populated with information
        bindingResult - request binding result to retrieve validation errors from
        redirectModel - page model used for redirection to be populated with information
        Returns:
        the url to which the request will be redirected
        Throws:
        de.hybris.platform.cms2.exceptions.CMSItemNotFoundException - if the CmsPage cannot be found, while populating the model with meta data or title information
      • updateCartQuantities

        @RequestMapping(value="/update",
                        method=POST)
        public java.lang.String updateCartQuantities​(@RequestParam("entryNumber")
                                                     long entryNumber,
                                                     org.springframework.ui.Model model,
                                                     @Valid
                                                     @Valid UpdateQuantityForm form,
                                                     org.springframework.validation.BindingResult bindingResult,
                                                     javax.servlet.http.HttpServletRequest request,
                                                     org.springframework.web.servlet.mvc.support.RedirectAttributes redirectModel)
                                              throws de.hybris.platform.cms2.exceptions.CMSItemNotFoundException
        Update the quantity of the product for the entry with the number given.
        Parameters:
        entryNumber - entry number of the cart entry to be updated
        model - page model to be populated with information
        form - update quantity form specifying the new quantity of the product from the entry with the number given
        bindingResult - request binding result to retrieve validation errors from
        request - http request to retrieve the url from
        redirectModel - redirect model to be populated with information
        Returns:
        the url to the result page
        Throws:
        de.hybris.platform.cms2.exceptions.CMSItemNotFoundException - if the CmsPage cannot be found, while populating the model with meta data or title information
      • handleUpdateQuantityFailure

        protected void handleUpdateQuantityFailure​(long newQuantity,
                                                   javax.servlet.http.HttpServletRequest request,
                                                   org.springframework.web.servlet.mvc.support.RedirectAttributes redirectModel,
                                                   CartModificationData cartModification)
        Handles the case when the update quantity call failed by adding corresponding error messages on the redirectModel.
        Parameters:
        newQuantity - the new quantity, as set by the customer
        request - http request to retrieve the url from
        redirectModel - redirect model to be populated with information
        cartModification - resulting cart modification after applying the quantity update
      • populatePageModelWithErrors

        protected void populatePageModelWithErrors​(org.springframework.ui.Model model,
                                                   org.springframework.validation.BindingResult bindingResult)
        Populates the page model with the errors found on the binding result given.
        Parameters:
        model - page model to be populated with errors
        bindingResult - binding result to retrieve the errors from
      • createProductList

        protected void createProductList​(org.springframework.ui.Model model)
                                  throws de.hybris.platform.cms2.exceptions.CMSItemNotFoundException
        Overrides:
        createProductList in class AbstractCartPageController
        Throws:
        de.hybris.platform.cms2.exceptions.CMSItemNotFoundException
      • setResourceBreadcrumbBuilder

        public void setResourceBreadcrumbBuilder​(ResourceBreadcrumbBuilder resourceBreadcrumbBuilder)
      • initBinder

        @InitBinder
        public void initBinder​(org.springframework.web.bind.WebDataBinder binder)