@RequestMapping(value = "/viewCart.htm", params = "addPromo", method = RequestMethod.POST)
  public String addPromoCode(
      @ModelAttribute(value = "cartSummary") CartSummary cartSummary,
      ModelMap model,
      HttpServletRequest request)
      throws PricingException {
    Order currentCartOrder = retrieveCartOrder(request, model);

    if (cartSummary.getPromoCode() != null) {
      OfferCode code = offerService.lookupOfferCodeByCode(cartSummary.getPromoCode());

      if (code != null) {
        try {
          currentCartOrder = cartService.addOfferCode(currentCartOrder, code, true);
        } catch (OfferMaxUseExceededException e) {
          model.addAttribute("error", "Promotion Max Uses Exceeded");
        }
        currentCartOrder = updateFulfillmentGroups(cartSummary, currentCartOrder);
      } else {
        model.addAttribute("promoError", "Invalid promo code entered.");
      }
    }

    cartSummary.setPromoCode(null);
    model.addAttribute("currentCartOrder", currentCartOrder);
    model.addAttribute("cartSummary", cartSummary);
    return cartView;
  }
 @Override
 @Transactional("blTransactionManager")
 public Order addOfferCode(Order order, OfferCode offerCode, boolean priceOrder)
     throws PricingException, OfferMaxUseExceededException {
   if (!order.getAddedOfferCodes().contains(offerCode)) {
     if (!offerService.verifyMaxCustomerUsageThreshold(
         order.getCustomer(), offerCode.getOffer())) {
       throw new OfferMaxUseExceededException(
           "The customer has used this offer code more than the maximum allowed number of times.");
     }
     order.getAddedOfferCodes().add(offerCode);
     order = save(order, priceOrder);
   }
   return order;
 }
  @RequestMapping(
      value = "/viewCart.htm",
      params = "removePromoFromCart",
      method = {RequestMethod.GET, RequestMethod.POST})
  public String removePromoCode(
      @RequestParam String orderOfferCode,
      @ModelAttribute CartSummary cartSummary,
      ModelMap model,
      HttpServletRequest request) {
    Order currentCartOrder = retrieveCartOrder(request, model);
    try {
      currentCartOrder =
          cartService.removeOfferCode(
              currentCartOrder, offerService.lookupOfferCodeByCode(orderOfferCode), true);
    } catch (PricingException e) {
      model.addAttribute("error", "remove");
      LOG.error(
          "An error occurred while removing a promo from the cart: (" + orderOfferCode + ")", e);
    }
    cartSummary.setOrderDiscounts(currentCartOrder.getTotalAdjustmentsValue().getAmount());

    return "redirect:/basket/viewCart.htm";
  }