Skip to content

Commit

Permalink
View: Accounting for authenticated user in checkout page to ensure pr…
Browse files Browse the repository at this point in the history
…oducts are listed on the checkout page
  • Loading branch information
Python-David committed Feb 4, 2024
1 parent 0a2fe79 commit 18b4ea7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def merge_cart_items(request, user):

# Try to find a matching cart item for the user
matching_item = None
user_cart_items = CartItem.objects.filter(user=user, product=guest_item.product)
user_cart_items = CartItem.objects.filter(
user=user, product=guest_item.product
)
for item in user_cart_items:
if product_variations == set(item.variations.all()):
matching_item = item
Expand Down Expand Up @@ -84,7 +86,7 @@ def redirect_to_next_page(request):

try:
query = requests.utils.urlparse(url).query
params = dict(x.split('=') for x in query.split('&') if '=' in x)
params = dict(x.split("=") for x in query.split("&") if "=" in x)
next_page = params.get("next")
if next_page:
return redirect(next_page)
Expand Down
2 changes: 1 addition & 1 deletion accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
RESET_PASSWORD_SUBJECT,
RESET_PASSWORD_SUCCESS_MESSAGE,
)
from .utils import merge_cart_items, send_email, redirect_to_next_page
from .utils import merge_cart_items, redirect_to_next_page, send_email


def register(request):
Expand Down

0 comments on commit 18b4ea7

Please sign in to comment.