Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Re-Added quantities to "add item to cart" view, by popular demand

  • Loading branch information...
commit b787b2eff75135a2e1e1337370e767a035b7c56b 1 parent cf045a6
@chrisglass chrisglass authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 shop/views/
11 shop/views/
@@ -125,14 +125,17 @@ def get(self, request, *args, **kwargs):
def post(self, *args, **kwargs):
- This is to *add* a new item to the cart, therefore the quantity is
- irrelevant (it should always be 1)
+ This is to *add* a new item to the cart. Optionally, you can pass it a
+ quantity parameter to specify how many you wish to add at once (defaults
+ to 1)
item_id = self.request.POST['add_item_id']
+ item_quantity = self.request.POST.get('add_item_quantity')
+ if not item_quantity:
+ item_quantity = 1
item = Product.objects.get(pk=item_id)
cart_object = get_or_create_cart(self.request)
- cart_object.add_product(item)
+ cart_object.add_product(item, item_quantity)
return self.post_success(item)
Please sign in to comment.
Something went wrong with that request. Please try again.