refactor cart_checkout logic ordering to keep people on the cart page
for as long as needed to get a valid cart before asking for address or billing. modified: make_post_sell/views/cart.py
This commit is contained in:
parent
6b471b6ecd
commit
3ca8ca1190
1 changed files with 29 additions and 25 deletions
|
|
@ -403,38 +403,42 @@ def cart_checkout(request):
|
|||
elif cart.is_empty:
|
||||
msg = ("That cart is empty, you cannot checkout.", "error")
|
||||
|
||||
elif cart.physical_products and not cart.handling_option:
|
||||
msg = ("Please select a handling option for your physical items.", "error")
|
||||
|
||||
elif cart.physical_products and not request.user.active_address:
|
||||
msg = ("Please add a shipping address to proceed with checkout.", "info")
|
||||
request.session.flash(msg)
|
||||
return HTTPFound("/u/addresses")
|
||||
|
||||
elif cart.requires_payment and stripe_user_shop is None:
|
||||
msg = ("Please enter your payment information.", "info")
|
||||
request.session.flash(msg)
|
||||
return HTTPFound("/billing")
|
||||
|
||||
elif stripe_user_shop.active_card is None:
|
||||
msg = ("Please make a payment method active.", "info")
|
||||
request.session.flash(msg)
|
||||
return HTTPFound("/billing")
|
||||
|
||||
else:
|
||||
# make sure all coupon terms are met before proceeding.
|
||||
# Validate coupons first
|
||||
error_messages = cart.validate_attached_coupons()
|
||||
if error_messages:
|
||||
for error_message in error_messages:
|
||||
request.session.flash((error_message, "error"))
|
||||
return HTTPFound(get_referer_or_home(request))
|
||||
|
||||
# check inventory for physical products.
|
||||
inventory_errors = cart.check_inventory(request.shop_location)
|
||||
if inventory_errors:
|
||||
for error_message in inventory_errors:
|
||||
request.session.flash((error_message, "error"))
|
||||
return HTTPFound(get_referer_or_home(request))
|
||||
# Check handling options, inventory, and address for physical products
|
||||
if cart.physical_products:
|
||||
inventory_errors = cart.check_inventory(request.shop_location)
|
||||
if inventory_errors:
|
||||
for error_message in inventory_errors:
|
||||
request.session.flash((error_message, "error"))
|
||||
return HTTPFound(get_referer_or_home(request))
|
||||
|
||||
if not cart.handling_option:
|
||||
msg = ("Please select a handling option for your physical items.", "error")
|
||||
request.session.flash(msg)
|
||||
return HTTPFound(get_referer_or_home(request))
|
||||
|
||||
if not request.user.active_address:
|
||||
msg = ("Please add a shipping address to proceed with checkout.", "info")
|
||||
request.session.flash(msg)
|
||||
return HTTPFound("/u/addresses")
|
||||
|
||||
# Check for payment information
|
||||
if cart.requires_payment and stripe_user_shop is None:
|
||||
msg = ("Please enter your payment information.", "info")
|
||||
request.session.flash(msg)
|
||||
return HTTPFound("/billing")
|
||||
|
||||
if stripe_user_shop.active_card is None:
|
||||
msg = ("Please make a payment method active.", "info")
|
||||
request.session.flash(msg)
|
||||
return HTTPFound("/billing")
|
||||
|
||||
msg = ("Please confirm your order.", "info")
|
||||
request.session.flash(msg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue