Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move note to checkout summary page
Jon Lawrence821aaad336b8
diff --git a/saleor/checkout/urls.py b/saleor/checkout/urls.pyindex 879c31fe89..a4c4ba92dd 100644--- a/saleor/checkout/urls.py+++ b/saleor/checkout/urls.py@@ -9,7 +9,6 @@ urlpatterns = [name='shipping-address'),url(r'^shipping-method/', views.shipping_method_view,name='shipping-method'),- url(r'^note/', views.note_view, name='note'),url(r'^summary/', views.summary_view, name='summary'),url(r'^remove_voucher/', views.discount.remove_voucher_view,name='remove-voucher'),diff --git a/saleor/checkout/views/__init__.py b/saleor/checkout/views/__init__.pyindex fb70f56db1..870b9c779b 100644--- a/saleor/checkout/views/__init__.py+++ b/saleor/checkout/views/__init__.py@@ -49,7 +49,7 @@ def shipping_method_view(request, checkout):initial={'method': checkout.shipping_method})if shipping_method_form.is_valid():checkout.shipping_method = shipping_method_form.cleaned_data['method']- return redirect('checkout:note')+ return redirect('checkout:summary')return TemplateResponse(request, 'checkout/shipping_method.html',context={diff --git a/saleor/checkout/views/summary.py b/saleor/checkout/views/summary.pyindex 023017cee8..f105ff949b 100644--- a/saleor/checkout/views/summary.py+++ b/saleor/checkout/views/summary.py@@ -93,6 +93,10 @@ def summary_with_shipping_view(request, checkout):Will create an order if all data is valid."""+ note_form = NoteForm(request.POST or None)+ if note_form.is_valid():+ checkout.note = note_form.cleaned_data['note']+if request.user.is_authenticated:additional_addresses = request.user.addresses.all()else:@@ -108,7 +112,8 @@ def summary_with_shipping_view(request, checkout):request, 'checkout/summary.html', context={'addresses_form': addresses_form, 'address_form': address_form,'checkout': checkout,- 'additional_addresses': additional_addresses})+ 'additional_addresses': additional_addresses,+ 'note_form': note_form})def anonymous_summary_without_shipping(request, checkout):@@ -116,6 +121,10 @@ def anonymous_summary_without_shipping(request, checkout):Will create an order if all data is valid."""+ note_form = NoteForm(request.POST or None)+ if note_form.is_valid():+ checkout.note = note_form.cleaned_data['note']+user_form = AnonymousUserBillingForm(request.POST or None, initial={'email': checkout.email})billing_address = checkout.billing_address@@ -134,7 +143,8 @@ def anonymous_summary_without_shipping(request, checkout):return TemplateResponse(request, 'checkout/summary_without_shipping.html', context={'user_form': user_form, 'address_form': address_form,- 'checkout': checkout})+ 'checkout': checkout,+ 'note_form': note_form})def summary_without_shipping(request, checkout):@@ -142,6 +152,10 @@ def summary_without_shipping(request, checkout):Will create an order if all data is valid."""+ note_form = NoteForm(request.POST or None)+ if note_form.is_valid():+ checkout.note = note_form.cleaned_data['note']+billing_address = checkout.billing_addressuser_addresses = request.user.addresses.all()if billing_address and billing_address.id:@@ -179,4 +193,5 @@ def summary_without_shipping(request, checkout):return TemplateResponse(request, 'checkout/summary_without_shipping.html', context={'addresses_form': addresses_form, 'address_form': address_form,- 'checkout': checkout, 'additional_addresses': user_addresses})+ 'checkout': checkout, 'additional_addresses': user_addresses,+ 'note_form': note_form})diff --git a/saleor/checkout/views/validators.py b/saleor/checkout/views/validators.pyindex c9196585f4..78e008fdf2 100644--- a/saleor/checkout/views/validators.py+++ b/saleor/checkout/views/validators.py@@ -63,11 +63,11 @@ def validate_is_shipping_required(view):Expects to be decorated with `@validate_cart`.- If shipping is not needed redirects to the note step.+ If shipping is not needed redirects to the checkout summary."""@wraps(view)def func(request, checkout):if not checkout.is_shipping_required:- return redirect('checkout:note')+ return redirect('checkout:summary')return view(request, checkout)return funcdiff --git a/templates/checkout/summary.html b/templates/checkout/summary.htmlindex f507aefb5c..d4943119a3 100644--- a/templates/checkout/summary.html+++ b/templates/checkout/summary.html@@ -6,6 +6,8 @@{% csrf_token %}<h2>{% trans "Billing address" context "Checkout summary title" %}</h2>{% include "checkout/snippets/addresses_form.html" with addresses_form=addresses_form addresses=additional_addresses address_form=address_form only %}+ <h2>{% trans "Add a note to your order" context "Checkout summary note title" %}</h2>+ {% bootstrap_form note_form show_label=False %}<p class="text-md-right"><button type="submit" class="btn primary">{% trans "Order & Pay" context "Checkout summary primary action" %}diff --git a/templates/checkout/summary_without_shipping.html b/templates/checkout/summary_without_shipping.htmlindex 9acfaa4ac5..36f7179e80 100644--- a/templates/checkout/summary_without_shipping.html+++ b/templates/checkout/summary_without_shipping.html@@ -12,6 +12,8 @@{% bootstrap_form user_form %}{% include "userprofile/snippets/address_form.html" with address_form=address_form only %}{% endif %}+ <h2>{% trans "Add a note to your order" context "Checkout summary without shipping note title" %}</h2>+ {% bootstrap_form note_form show_label=False %}<p class="text-md-right"><button type="submit" class="btn primary">{% trans "Place order" context "Checkout summary without shipping action" %}