fix delete cartitems after purchase

This commit is contained in:
Ivan Hörler 2018-02-27 07:22:57 +01:00
parent d0c5cd6893
commit d38a37536a
1 changed files with 15 additions and 0 deletions

View File

@ -402,4 +402,19 @@ def checkout(request):
def order(request):
cart = ShoppingCart.objects.get(user=request.user)
if cart:
# get all items in the cart of this customer:
cart_positions = CartPosition.objects.filter(cart=cart)
if (cart_positions.count()) > 0:
for cart_position in cart_positions:
restrict_cart_to_one_article(
request.user,
cart_position.article.id,
0,
'delete'
)
else:
message = """something whent wrong.
We cold not delete your cartitems. """
return render(request, 'webshop/order.html', {})