Class TmaCartsController


  • @Controller
    @RequestMapping("/{baseSiteId}/users/{userId}/carts")
    public class TmaCartsController
    extends BaseController
    Controller for cart related requests such as retrieving/delete/update/... a cart
    Since:
    1911
    • Constructor Detail

      • TmaCartsController

        public TmaCartsController()
    • Method Detail

      • getCarts

        @RequestMapping(method=GET)
        @ResponseBody
        public CartListWsDTO getCarts​(@RequestParam(required=false,defaultValue="DEFAULT")
                                      java.lang.String fields,
                                      @RequestParam(defaultValue="false")
                                      boolean savedCartsOnly,
                                      @RequestParam(defaultValue="0")
                                      int currentPage,
                                      @RequestParam(defaultValue="20")
                                      int pageSize,
                                      @RequestParam(required=false)
                                      java.lang.String sort)
      • getCart

        @RequestMapping(value="/{cartId}",
                        method=GET)
        @ResponseBody
        public CartWsDTO getCart​(@PathVariable("cartId")
                                 java.lang.String cartId,
                                 @PathVariable("userId")
                                 java.lang.String userId,
                                 @RequestParam(defaultValue="DEFAULT")
                                 java.lang.String fields)
      • createCartEntry

        @RequestMapping(value="/{cartId}/entries",
                        method=POST,
                        consumes={"application/json","application/xml"})
        @ResponseBody
        public CartModificationWsDTO createCartEntry​(@PathVariable("cartId")
                                                     java.lang.String cartId,
                                                     @PathVariable("userId")
                                                     java.lang.String userId,
                                                     @PathVariable
                                                     java.lang.String baseSiteId,
                                                     @RequestBody
                                                     OrderEntryWsDTO entry,
                                                     @RequestParam(defaultValue="DEFAULT")
                                                     java.lang.String fields)
                                              throws de.hybris.platform.commerceservices.order.CommerceCartModificationException
        Throws:
        de.hybris.platform.commerceservices.order.CommerceCartModificationException
      • createCart

        @RequestMapping(method=POST)
        @ResponseStatus(CREATED)
        @ResponseBody
        public CartWsDTO createCart​(@RequestParam(required=false)
                                    java.lang.String oldCartId,
                                    @RequestParam(required=false)
                                    java.lang.String toMergeCartGuid,
                                    @PathVariable("userId")
                                    java.lang.String userId,
                                    @RequestParam(defaultValue="DEFAULT")
                                    java.lang.String fields)
      • removeCartEntry

        @RequestMapping(value="/{cartId}/entries/{entryNumber}",
                        method=DELETE)
        @ResponseStatus(OK)
        public void removeCartEntry​(@PathVariable
                                    long entryNumber,
                                    @PathVariable("cartId")
                                    java.lang.String cartId,
                                    @PathVariable("userId")
                                    java.lang.String userId)
                             throws de.hybris.platform.commerceservices.order.CommerceCartModificationException
        Throws:
        de.hybris.platform.commerceservices.order.CommerceCartModificationException
      • updateCartEntry

        @RequestMapping(value="/{cartId}/entries/{entryNumber}",
                        method=PATCH,
                        consumes={"application/json","application/xml"})
        @ResponseBody
        public CartModificationWsDTO updateCartEntry​(@PathVariable
                                                     java.lang.String baseSiteId,
                                                     @PathVariable
                                                     long entryNumber,
                                                     @RequestBody
                                                     OrderEntryWsDTO entry,
                                                     @RequestParam(defaultValue="DEFAULT")
                                                     java.lang.String fields,
                                                     @PathVariable("cartId")
                                                     java.lang.String cartId,
                                                     @PathVariable("userId")
                                                     java.lang.String userId)
                                              throws de.hybris.platform.commerceservices.order.CommerceCartModificationException
        Throws:
        de.hybris.platform.commerceservices.order.CommerceCartModificationException
      • mergeCarts

        protected CartWsDTO mergeCarts​(java.lang.String oldCartId,
                                       java.lang.String evaluatedToMergeCartGuid,
                                       java.lang.String userId,
                                       java.lang.String fields)
                                throws de.hybris.platform.commercewebservicescommons.errors.exceptions.CartException
        Merges anonymous cart with given user cart and returns user cart.
        Parameters:
        oldCartId - the old cart id
        evaluatedToMergeCartGuid - the evaluated to merge cart guid
        userId - the user id
        fields - the fields
        Returns:
        the cart ws DTO
        Throws:
        de.hybris.platform.commercewebservicescommons.errors.exceptions.CartException - the cart exception
      • getRestoredCart

        protected CartWsDTO getRestoredCart​(java.lang.String toMergeCartGuid,
                                            java.lang.String userId,
                                            java.lang.String fields)
                                     throws de.hybris.platform.commercewebservicescommons.errors.exceptions.CartException
        Gets restored cart or session cart when oldCartId is not provided.
        Parameters:
        toMergeCartGuid - the evaluated to merge cart guid
        userId - the user id
        fields - the fields
        Returns:
        the restored cart
        Throws:
        de.hybris.platform.commercewebservicescommons.errors.exceptions.CartException - the cart exception
      • addCartEntryInternal

        protected CartModificationWsDTO addCartEntryInternal​(java.lang.String baseSiteId,
                                                             java.lang.String fields,
                                                             OrderEntryWsDTO entry,
                                                             java.lang.Integer cartGroupNo,
                                                             java.lang.String cartId,
                                                             java.lang.String userId)
                                                      throws de.hybris.platform.commerceservices.order.CommerceCartModificationException
        Throws:
        de.hybris.platform.commerceservices.order.CommerceCartModificationException
      • createCartItemAction

        protected CartActionInput createCartItemAction​(OrderEntryWsDTO entry,
                                                       java.lang.String rootBpoCode,
                                                       java.lang.Integer cartGroupNo,
                                                       java.lang.String cartId,
                                                       java.lang.String userId,
                                                       java.lang.String pickupStore)
        Parameters:
        entry - the cart entry
        rootBpoCode - the bpo Code
        cartGroupNo - the group number
        cartId - the identifier of the shopping cart
        userId - the identifier of the user
        pickupStore - the identifier of the pickupStore
        Returns:
        instance of CartActionInput
      • setCpiInformation

        protected void setCpiInformation​(OrderEntryWsDTO entry,
                                         CartActionInput cartActionInput)
        Sets CPI related information
        Parameters:
        entry - the order entry
        cartActionInput - the cart action input
      • setProductCharacteristics

        protected void setProductCharacteristics​(OrderEntryWsDTO entry,
                                                 CartActionInput cartActionInput)
        Sets PSCV related data from the entry on the cartActionInput
        Parameters:
        entry - the order entry
        cartActionInput - the cart action input
      • populateDefaultCartEntryValues

        protected void populateDefaultCartEntryValues​(OrderEntryWsDTO entry)
                                               throws de.hybris.platform.commerceservices.order.CommerceCartModificationException
        Throws:
        de.hybris.platform.commerceservices.order.CommerceCartModificationException
      • validateIfProductIsInStockInPOS

        protected void validateIfProductIsInStockInPOS​(java.lang.String baseSiteId,
                                                       java.lang.String productCode,
                                                       java.lang.String storeName,
                                                       java.lang.Long entryNumber)
        Parameters:
        baseSiteId - the store identifier
        productCode - the product identifier
        storeName - the store name
        entryNumber - the long value for entry
      • initBinder

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