2 Replies Latest reply: Nov 15, 2012 2:29 AM by 967909 RSS

    Adding items to cart

    967909
      Hi
      i want to add only 1-10 items to cart not more than that how to write code for that logic?
      if any one know just share the data.
        • 1. Re: Adding items to cart
          karthik chopperla
          You can customize CartModifierFormhandler.addItemToOrder() method to check for the number of items in cart and throw an exception

          List commerceItems =getCurrent().getCommerceItems();
          if(commerceItems.size()>10)
          addFormException()

          (Or)

          You can also set a variable in cart.jsp which counts the number of items in cart while displaying the commerce items.
          Whenever user adds item to cart, write onclick java script function passing the size set at the top. The javascript function will check if value >10 and throw an error.

          -karthik
          • 2. Re: Adding items to cart
            967909
            Thanks karthik