Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix bad anonymous_user_email default value

Michal Ociepka2b59980e5e27
diff --git a/checkout/__init__.py b/checkout/__init__.py
index b223760f31..4f81db5167 100644
--- a/checkout/__init__.py
+++ b/checkout/__init__.py
@@ -14,7 +14,7 @@ class CheckoutStorage(dict):
def __init__(self, *args, **kwargs):
super(CheckoutStorage, self).__init__(*args, **kwargs)
- self.update({'anonymous_user_email': None, 'billing_address': None,
+ self.update({'anonymous_user_email': '', 'billing_address': None,
'groups': defaultdict(dict), 'summary': False})
@@ -58,7 +58,7 @@ class Checkout(ProcessManager):
@anonymous_user_email.deleter
def anonymous_user_email(self, email):
- self.storage['anonymous_user_email'] = None
+ self.storage['anonymous_user_email'] = ''
@property
def billing_address(self):
@@ -92,5 +92,8 @@ class Checkout(ProcessManager):
order = Order()
for step in self.steps:
step.add_to_order(order)
+ if self.request.user.is_authenticated():
+ order.user = self.request.user
+ order.anonymous_user_email = ''
order.save()
return order
diff --git a/checkout/steps.py b/checkout/steps.py
index 557b55e72a..d07d8e48fc 100644
--- a/checkout/steps.py
+++ b/checkout/steps.py
@@ -69,7 +69,7 @@ class BaseShippingStep(BaseCheckoutStep):
class BillingAddressStep(BaseShippingStep):
template = 'checkout/billing.html'
- anonymous_user_email = None
+ anonymous_user_email = ''
def __init__(self, checkout, request):
address = checkout.billing_address or Address()