Пример #1
0
    def get(self, request):
        cart = Cart(request)

        offer_id = request.GET.get('offer_id')
        offer = get_object_or_404(Offer, pk=offer_id)
        cart.remove(offer.id)
        return redirect('cart')
Пример #2
0
def decrease_quantity(request, pk):
    cart = Cart(request)
    item = get_object_or_404(Item, id=pk)
    item_id = str(item.id)
    print(cart.__dict__)
    if cart.cart[item_id]['quantity'] > 1:
        cart.add(item=item, quantity=-1)
    else:
        cart.remove(item)
    return redirect("ordersummary")
Пример #3
0
    def get(request):
        product_id = request.GET.get('product_id')

        cart = Cart(request)
        cart.remove(product_id)

        context = {
            'cart_len': len(cart),
        }
        return JsonResponse(context)
Пример #4
0
def remove_from_cart(request, pk):
    cart = Cart(request)
    item = get_object_or_404(Item, id=pk)
    cart.remove(item)
    return redirect("ordersummary")