Esempio n. 1
0
def remove_from_cart(request, product_id):
    """remove cart item"""
    cart = Cart(request)
    product_object = get_object_or_404(Product, id=product_id)
    if request.method == 'POST':
        cart.remove(product_object)
        cart.save_session()
    return redirect('orders:cart')
Esempio n. 2
0
def remove(request):
    cart = Cart(request)
    product_id = int(request.GET.get('product_id'))
    product = Product.objects.get(id=product_id)
    cart.remove(product)

    context = {
        'cart_len': len(cart),
        'total_price': cart.get_total_price(),
    }

    return JsonResponse(context)
Esempio n. 3
0
def cart_remove(request, slug):
    product = get_object_or_404(Product, slug=slug)
    cart = Cart(request)
    cart.remove(product)
    return conditional_redirect(request, reverse('show_cart'))
Esempio n. 4
0
def cart_remove(request, slug):
    product = get_object_or_404(Product, slug=slug)
    cart = Cart(request)
    cart.remove(product)
    return conditional_redirect(request, reverse('show_cart'))
Esempio n. 5
0
 def remove_from_cart(self, request, **kwargs):
     research = Research.objects.get(slug=self.request.GET.get('remove_from_cart'))
     cart = Cart(self.request)
     cart.remove(research)