PacktPublishing / Django-4-by-example

Django 4 by example (4th Edition) published by Packt
https://djangobyexample.com/
MIT License
818 stars 461 forks source link

Coupon is not removed after checkout and shows up in next session also #15

Closed shivampatel22 closed 1 year ago

shivampatel22 commented 2 years ago

'coupon_id' should be removed from session after checkout is complete.

Steps to replicate

PRCervera commented 2 years ago

You have to add ...

request.session['coupon_id'] = None

after ...

cart.clear()

in cart's views.py

zenx commented 1 year ago

Thank you @PRCervera.

@shivampatel22 as @PRCervera mentions, you can remove coupon_id from the session in orders/views.py after clearing the cart in this line: https://github.com/PacktPublishing/Django-4-by-example/blob/f4d6a3df49fb851b96466bf6327dc93cc24f8f58/Chapter11/myshop/orders/views.py#L30

shivampatel22 commented 1 year ago

Thanks @PRCervera and @zenx.

Shush1k commented 1 year ago

I spent a little time thinking why the coupon stays in the session, then I thought I had missed this point in the book. Nice issue