Ejemplo n.º 1
0
def remove_from_cart(request, product_id):
	product = Product.objects.get(Productid=product_id)
	cart = Cart(request)
	try:
		cart.remove(product)
	except ItemDoesNotExist:
		pass
	return HttpResponseRedirect('/bookstore/cart/view')
Ejemplo n.º 2
0
def add_to_cart(request, product_id):
	product = Product.objects.get(Productid=product_id)
	cart = Cart(request)
	try:
		quantity = int(request.POST['quantity']) or 1
		cart.add(product, product.price, quantity)
	except ItemAlreadyExists:
		pass
	return HttpResponseRedirect('/bookstore/cart/view')
Ejemplo n.º 3
0
def clear_cart(request):
	cart = Cart(request)
	try:
		cart.clear()
	except Exception, exc:
		pass