@RequestMapping( value = "/cart/update", method = RequestMethod.POST, produces = "application/json") public String updateCartQuantities( @RequestParam("storeNamePost") final String storeId, @RequestParam("entryNumber") final long entryNumber, @RequestParam("hiddenPickupQty") final long quantity, final RedirectAttributes redirectModel) throws CommerceCartModificationException { final CartModificationData cartModificationData = cartFacade.updateCartEntry(entryNumber, storeId); if (entryNumber == cartModificationData.getEntry().getEntryNumber().intValue()) { final CartModificationData cartModification = cartFacade.updateCartEntry(entryNumber, quantity); if (cartModification.getQuantity() == quantity) { // Success if (cartModification.getQuantity() == 0) { // Success in removing entry GlobalMessages.addFlashMessage( redirectModel, GlobalMessages.CONF_MESSAGES_HOLDER, "basket.page.message.remove"); } else { // Success in update quantity GlobalMessages.addFlashMessage( redirectModel, GlobalMessages.CONF_MESSAGES_HOLDER, "basket.page.message.update.pickupinstoreitem"); } } else { // Less than successful GlobalMessages.addFlashMessage( redirectModel, GlobalMessages.ERROR_MESSAGES_HOLDER, "basket.information.quantity.reducedNumberOfItemsAdded." + cartModification.getStatusCode()); } } else if (!CommerceCartModificationStatus.SUCCESS.equals( cartModificationData.getStatusCode())) { // When update pickupInStore happens to be same as existing entry with POS and SKU and that // merged POS has lower stock GlobalMessages.addFlashMessage( redirectModel, GlobalMessages.ERROR_MESSAGES_HOLDER, "basket.information.quantity.reducedNumberOfItemsAdded." + cartModificationData.getStatusCode()); } return REDIRECT_PREFIX + "/cart"; }
@RequestMapping( value = "/cart/update/delivery", method = {RequestMethod.GET, RequestMethod.POST}) public String updateToDelivery( @RequestParam("entryNumber") final long entryNumber, final RedirectAttributes redirectModel) throws CommerceCartModificationException { final CartModificationData cartModificationData = cartFacade.updateCartEntry(entryNumber, null); if (CommerceCartModificationStatus.SUCCESS.equals(cartModificationData.getStatusCode())) { // Success in update quantity GlobalMessages.addFlashMessage( redirectModel, GlobalMessages.CONF_MESSAGES_HOLDER, "basket.page.message.update.pickupinstoreitem.toship"); } else { // Less than successful GlobalMessages.addFlashMessage( redirectModel, GlobalMessages.ERROR_MESSAGES_HOLDER, "basket.information.quantity.reducedNumberOfItemsAdded." + cartModificationData.getStatusCode()); } return REDIRECT_PREFIX + "/cart"; }