|
|
@@ -183,24 +183,14 @@ class ShippingAddressView(CheckoutSessionMixin, FormView):
|
|
183
|
183
|
|
|
184
|
184
|
# Check to see that a shipping address is actually required. It may not be if
|
|
185
|
185
|
# the basket is purely downloads
|
|
186
|
|
- if not self.does_basket_require_shipping(request.basket):
|
|
|
186
|
+ if not request.basket.is_shipping_required():
|
|
187
|
187
|
messages.info(request, _("Your basket does not require a shipping address to be submitted"))
|
|
188
|
|
- self.checkout_session.no_shipping_required()
|
|
189
|
188
|
return HttpResponseRedirect(self.get_success_url())
|
|
190
|
189
|
else:
|
|
191
|
190
|
self.checkout_session.shipping_required()
|
|
192
|
191
|
|
|
193
|
192
|
return super(ShippingAddressView, self).get(request, *args, **kwargs)
|
|
194
|
193
|
|
|
195
|
|
- def does_basket_require_shipping(self, basket):
|
|
196
|
|
- """
|
|
197
|
|
- Test whether the contents of the basket require shipping
|
|
198
|
|
- """
|
|
199
|
|
- for line in basket.all_lines():
|
|
200
|
|
- if line.product.is_shipping_required:
|
|
201
|
|
- return True
|
|
202
|
|
- return False
|
|
203
|
|
-
|
|
204
|
194
|
def get_initial(self):
|
|
205
|
195
|
return self.checkout_session.new_shipping_address_fields()
|
|
206
|
196
|
|
|
|
@@ -322,7 +312,7 @@ class ShippingMethodView(CheckoutSessionMixin, TemplateView):
|
|
322
|
312
|
|
|
323
|
313
|
def get(self, request, *args, **kwargs):
|
|
324
|
314
|
# Check that shipping is required at all
|
|
325
|
|
- if not self.checkout_session.is_shipping_required():
|
|
|
315
|
+ if not request.basket.is_shipping_required():
|
|
326
|
316
|
self.checkout_session.use_shipping_method(NoShippingRequired().code)
|
|
327
|
317
|
return self.get_success_response()
|
|
328
|
318
|
|
|
|
@@ -398,7 +388,7 @@ class PaymentMethodView(CheckoutSessionMixin, TemplateView):
|
|
398
|
388
|
|
|
399
|
389
|
def get(self, request, *args, **kwargs):
|
|
400
|
390
|
# Check that shipping address has been completed
|
|
401
|
|
- if self.checkout_session.is_shipping_required() and not self.checkout_session.is_shipping_address_set():
|
|
|
391
|
+ if request.basket.is_shipping_required() and not self.checkout_session.is_shipping_address_set():
|
|
402
|
392
|
messages.error(request, _("Please choose a shipping address"))
|
|
403
|
393
|
return HttpResponseRedirect(reverse('checkout:shipping-address'))
|
|
404
|
394
|
# Check that shipping method has been set
|
|
|
@@ -516,7 +506,7 @@ class OrderPlacementMixin(CheckoutSessionMixin):
|
|
516
|
506
|
If the shipping address was selected from the user's address book,
|
|
517
|
507
|
then we convert the UserAddress to a ShippingAddress.
|
|
518
|
508
|
"""
|
|
519
|
|
- if not self.checkout_session.is_shipping_required():
|
|
|
509
|
+ if not self.request.basket.is_shipping_required():
|
|
520
|
510
|
return None
|
|
521
|
511
|
|
|
522
|
512
|
addr_data = self.checkout_session.new_shipping_address_fields()
|
|
|
@@ -674,7 +664,7 @@ class PaymentDetailsView(OrderPlacementMixin, TemplateView):
|
|
674
|
664
|
|
|
675
|
665
|
def get_error_response(self):
|
|
676
|
666
|
# Check that shipping address has been completed
|
|
677
|
|
- if self.checkout_session.is_shipping_required() and not self.checkout_session.is_shipping_address_set():
|
|
|
667
|
+ if self.request.basket.is_shipping_required() and not self.checkout_session.is_shipping_address_set():
|
|
678
|
668
|
messages.error(self.request, _("Please choose a shipping address"))
|
|
679
|
669
|
return HttpResponseRedirect(reverse('checkout:shipping-address'))
|
|
680
|
670
|
# Check that shipping method has been set
|
|
|
@@ -695,6 +685,7 @@ class PaymentDetailsView(OrderPlacementMixin, TemplateView):
|
|
695
|
685
|
then the method can call submit()
|
|
696
|
686
|
"""
|
|
697
|
687
|
error_response = self.get_error_response()
|
|
|
688
|
+
|
|
698
|
689
|
if error_response:
|
|
699
|
690
|
return error_response
|
|
700
|
691
|
if self.preview:
|