Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move rest of checkout to the cart app
Anna Siwik1ff35fff600f
diff --git a/saleor/checkout/core.py b/saleor/cart/checkout/core.pysimilarity index 95%rename from saleor/checkout/core.pyrename to saleor/cart/checkout/core.pyindex 05aac026ae..49a7ee0a35 100644--- a/saleor/checkout/core.py+++ b/saleor/cart/checkout/core.py@@ -7,16 +7,16 @@ from django.utils.encoding import smart_textfrom django.utils.translation import get_languagefrom prices import Money-from ..account.models import Address-from ..account.utils import store_user_address-from ..cart.models import Cart-from ..cart.utils import get_or_empty_db_cart-from ..core import analytics-from ..core.utils.taxes import get_taxes_for_country-from ..discount.models import NotApplicable, Voucher-from ..discount.utils import increase_voucher_usage-from ..order.models import Order-from ..order.utils import add_variant_to_order+from ...account.models import Address+from ...account.utils import store_user_address+from ...core import analytics+from ...core.utils.taxes import get_taxes_for_country+from ...discount.models import NotApplicable, Voucher+from ...discount.utils import increase_voucher_usage+from ...order.models import Order+from ...order.utils import add_variant_to_order+from ..models import Cart+from ..utils import get_or_empty_db_cartfrom .utils import get_voucher_discount_for_checkoutSTORAGE_SESSION_KEY = 'checkout_storage'@@ -225,7 +225,7 @@ class Checkout:order_data['user'] = self.userorder_data['user_email'] = self.user.emailelse:- order_data['user_email'] = self.email+ order_data['user_email'] = self.cart.user_emailif voucher is not None:order_data['voucher'] = voucherdiff --git a/saleor/cart/checkout/forms.py b/saleor/cart/checkout/forms.pyindex 60786fb376..2e779dc42f 100644--- a/saleor/cart/checkout/forms.py+++ b/saleor/cart/checkout/forms.py@@ -5,7 +5,6 @@ from django.utils.translation import pgettext_lazyfrom ...cart.models import Cartfrom ...core.utils import format_moneyfrom ...core.utils.taxes import display_gross_prices-from ...checkout.forms import CheckoutAddressFieldfrom ...shipping.models import ShippingMethodCountryfrom ...shipping.utils import get_taxed_shipping_price@@ -34,6 +33,10 @@ class AnonymousUserBillingForm(forms.ModelForm):fields = ['user_email']+class RadioSelectChoiceField(forms.ChoiceField):+ widget = forms.RadioSelect()++class AddressChoiceForm(forms.Form):"""Choose one of user's addresses or to create new one."""@@ -42,7 +45,7 @@ class AddressChoiceForm(forms.Form):(NEW_ADDRESS, pgettext_lazy('Shipping addresses form choice', 'Enter a new address'))]- address = CheckoutAddressField(+ address = RadioSelectChoiceField(label=pgettext_lazy('Shipping addresses form field label', 'Address'),choices=CHOICES, initial=NEW_ADDRESS)@@ -64,7 +67,7 @@ class BillingAddressChoiceForm(AddressChoiceForm):(SHIPPING_ADDRESS, pgettext_lazy('Billing addresses form choice', 'Same as shipping'))]- address = CheckoutAddressField(+ address = RadioSelectChoiceField(label=pgettext_lazy('Billing addresses form field label', 'Address'),choices=CHOICES, initial=SHIPPING_ADDRESS)diff --git a/saleor/cart/checkout/urls.py b/saleor/cart/checkout/urls.pynew file mode 100644index 0000000000..23d7da5477--- /dev/null+++ b/saleor/cart/checkout/urls.py@@ -0,0 +1,15 @@+from django.conf.urls import url++from . import views+from .views.discount import remove_voucher_view++urlpatterns = [+ url(r'^$', views.index_view, name='checkout-index'),+ url(r'^shipping-address/', views.shipping_address_view,+ name='checkout-shipping-address'),+ url(r'^shipping-method/', views.shipping_method_view,+ name='checkout-shipping-method'),+ url(r'^summary/', views.summary_view, name='checkout-summary'),+ url(r'^remove_voucher/', remove_voucher_view,+ name='checkout-remove-voucher'),+ url(r'^login/', views.login, name='checkout-login')]diff --git a/saleor/cart/checkout/utils.py b/saleor/cart/checkout/utils.pyindex 1c120e0e97..28323ab001 100644--- a/saleor/cart/checkout/utils.py+++ b/saleor/cart/checkout/utils.py@@ -1,3 +1,14 @@+from django.utils.translation import pgettext++from ...cart.utils import (+ get_category_variants_and_prices, get_product_variants_and_prices)+from ...discount import VoucherType+from ...discount.models import NotApplicable+from ...discount.utils import (+ get_product_or_category_voucher_discount, get_shipping_voucher_discount,+ get_value_voucher_discount)++def save_billing_address_in_cart(cart, address):"""Save billing address in cart if changed.@@ -50,3 +61,66 @@ def get_checkout_data(cart, discounts, taxes):'cart_lines': lines,'cart_subtotal': subtotal,'cart_shipping_price': shipping_price}+++def _get_value_voucher_discount_for_checkout(voucher, checkout):+ """Calculate discount value for a voucher of value type."""+ return get_value_voucher_discount(voucher, checkout.get_subtotal())+++def _get_shipping_voucher_discount_for_checkout(voucher, checkout):+ """Calculate discount value for a voucher of shipping type."""+ if not checkout.cart.is_shipping_required():+ msg = pgettext(+ 'Voucher not applicable',+ 'Your order does not require shipping.')+ raise NotApplicable(msg)+ shipping_method = checkout.cart.shipping_method+ if not shipping_method:+ msg = pgettext(+ 'Voucher not applicable',+ 'Please select a shipping method first.')+ raise NotApplicable(msg)+ not_valid_for_country = (+ voucher.apply_to and shipping_method.country_code != voucher.apply_to)+ if not_valid_for_country:+ msg = pgettext(+ 'Voucher not applicable',+ 'This offer is only valid in %(country)s.')+ raise NotApplicable(+ msg % {'country': voucher.get_apply_to_display()})+ return get_shipping_voucher_discount(+ voucher, checkout.get_subtotal(), shipping_method.get_total_price())+++def _get_product_or_category_voucher_discount_for_checkout(voucher, checkout):+ """Calculate discount value for a voucher of product or category type."""+ if voucher.type == VoucherType.PRODUCT:+ prices = [+ variant_price for _, variant_price in+ get_product_variants_and_prices(checkout.cart, voucher.product)]+ else:+ prices = [+ variant_price for _, variant_price in+ get_category_variants_and_prices(checkout.cart, voucher.category)]+ if not prices:+ msg = pgettext(+ 'Voucher not applicable',+ 'This offer is only valid for selected items.')+ raise NotApplicable(msg)+ return get_product_or_category_voucher_discount(voucher, prices)+++def get_voucher_discount_for_checkout(voucher, checkout):+ """Calculate discount value depending on voucher and discount types.++ Raise NotApplicable if voucher of given type cannot be applied.+ """+ if voucher.type == VoucherType.VALUE:+ return _get_value_voucher_discount_for_checkout(voucher, checkout)+ if voucher.type == VoucherType.SHIPPING:+ return _get_shipping_voucher_discount_for_checkout(voucher, checkout)+ if voucher.type in (VoucherType.PRODUCT, VoucherType.CATEGORY):+ return _get_product_or_category_voucher_discount_for_checkout(+ voucher, checkout)+ raise NotImplementedError('Unknown discount type')diff --git a/saleor/cart/checkout/views/__init__.py b/saleor/cart/checkout/views/__init__.pyindex 6cc98e1b78..8feac2883c 100644--- a/saleor/cart/checkout/views/__init__.py+++ b/saleor/cart/checkout/views/__init__.py@@ -1,18 +1,37 @@from django.shortcuts import redirectfrom django.template.response import TemplateResponse-from ....checkout.core import load_checkout-from ....checkout.views import add_voucher_form, validate_voucher-from ....checkout.views.validators import (- validate_cart, validate_is_shipping_required, validate_shipping_address,- validate_shipping_method)+from ....account.forms import LoginForm+from ..core import load_checkoutfrom ..forms import CartShippingMethodFormfrom ..utils import get_checkout_data+from .discount import add_voucher_form, validate_voucherfrom .shipping import (anonymous_user_shipping_address_view, user_shipping_address_view)from .summary import (anonymous_summary_without_shipping, summary_with_shipping_view,summary_without_shipping)+from .validators import (+ validate_cart, validate_is_shipping_required, validate_shipping_address,+ validate_shipping_method)+++@load_checkout+@validate_cart+def login(request, cart, checkout):+ """Allow the user to log in prior to checkout."""+ if request.user.is_authenticated:+ return redirect('cart:checkout-index')+ form = LoginForm()+ return TemplateResponse(request, 'checkout/login.html', {'form': form})+++@load_checkout+@validate_cart+@validate_is_shipping_required+def index_view(request, cart, checkout):+ """Redirect to the initial step of checkout."""+ return redirect('cart:checkout-shipping-address')@load_checkout@@ -42,7 +61,7 @@ def shipping_method_view(request, cart, checkout):if form.is_valid():form.save()- return redirect('checkout:summary')+ return redirect('cart:checkout-summary')ctx = get_checkout_data(cart, request.discounts, taxes)ctx.update({diff --git a/saleor/checkout/views/discount.py b/saleor/cart/checkout/views/discount.pysimilarity index 94%rename from saleor/checkout/views/discount.pyrename to saleor/cart/checkout/views/discount.pyindex 5c2e83f320..380295fa69 100644--- a/saleor/checkout/views/discount.py+++ b/saleor/cart/checkout/views/discount.py@@ -7,8 +7,8 @@ from django.template.response import TemplateResponsefrom django.utils.translation import pgettextfrom django.views.decorators.http import require_POST-from ...discount.forms import CheckoutDiscountForm-from ...discount.models import Voucher+from ....discount.forms import CheckoutDiscountForm+from ....discount.models import Voucherfrom ..core import load_checkout@@ -62,7 +62,7 @@ def validate_voucher(view):'Checkout warning','This voucher has expired. Please review your checkout.')messages.warning(request, msg)- return redirect('checkout:summary')+ return redirect('cart:checkout-summary')return view(request, cart, checkout)return funcdiff --git a/saleor/cart/checkout/views/shipping.py b/saleor/cart/checkout/views/shipping.pyindex 36d8826c3a..2adc12b5ca 100644--- a/saleor/cart/checkout/views/shipping.py+++ b/saleor/cart/checkout/views/shipping.py@@ -22,7 +22,7 @@ def anonymous_user_shipping_address_view(request, cart, checkout):user_form.save()address = address_form.save()save_shipping_address_in_cart(cart, address)- return redirect('checkout:shipping-method')+ return redirect('cart:checkout-shipping-method')ctx = get_checkout_data(cart, request.discounts, checkout.get_taxes())ctx.update({@@ -73,12 +73,12 @@ def user_shipping_address_view(request, cart, checkout):address_id = addresses_form.cleaned_data['address']address = Address.objects.get(id=address_id)save_shipping_address_in_cart(cart, address)- return redirect('checkout:shipping-method')+ return redirect('cart:checkout-shipping-method')elif address_form.is_valid():address = address_form.save()save_shipping_address_in_cart(cart, address)- return redirect('checkout:shipping-method')+ return redirect('cart:checkout-shipping-method')ctx = get_checkout_data(cart, request.discounts, checkout.get_taxes())ctx.update({diff --git a/saleor/cart/checkout/views/summary.py b/saleor/cart/checkout/views/summary.pyindex 30ec079c20..35ba753b6b 100644--- a/saleor/cart/checkout/views/summary.py+++ b/saleor/cart/checkout/views/summary.py@@ -18,11 +18,11 @@ def create_order(checkout):This is a helper function.- `checkout` is a `saleor.checkout.core.Checkout` instance.+ `checkout` is a `saleor.cart.checkout.core.Checkout` instance."""order = checkout.create_order()if not order:- return None, redirect('checkout:summary')+ return None, redirect('cart:checkout-summary')checkout.clear_storage()checkout.cart.clear()user = None if checkout.user.is_anonymous else checkout.userdiff --git a/saleor/checkout/views/validators.py b/saleor/cart/checkout/views/validators.pysimilarity index 89%rename from saleor/checkout/views/validators.pyrename to saleor/cart/checkout/views/validators.pyindex 97ebc171ae..b59ed8701b 100644--- a/saleor/checkout/views/validators.py+++ b/saleor/cart/checkout/views/validators.py@@ -33,11 +33,11 @@ def validate_shipping_address(view):@wraps(view)def func(request, cart, checkout):if cart.user_email is None or cart.shipping_address is None:- return redirect('checkout:shipping-address')+ return redirect('cart:checkout-shipping-address')try:cart.shipping_address.full_clean()except ValidationError:- return redirect('checkout:shipping-address')+ return redirect('cart:checkout-shipping-address')return view(request, cart, checkout)return func@@ -52,7 +52,7 @@ def validate_shipping_method(view):@wraps(view)def func(request, cart, checkout):if cart.shipping_method is None:- return redirect('checkout:shipping-method')+ return redirect('cart:checkout-shipping-method')return view(request, cart, checkout)return func@@ -67,6 +67,6 @@ def validate_is_shipping_required(view):@wraps(view)def func(request, cart, checkout):if not cart.is_shipping_required():- return redirect('checkout:summary')+ return redirect('cart:checkout-summary')return view(request, cart, checkout)return funcdiff --git a/saleor/cart/migrations/0007_merge_checkout_into_cart.py b/saleor/cart/migrations/0007_merge_checkout_into_cart.pyindex f1d923eb0e..60232c1918 100644--- a/saleor/cart/migrations/0007_merge_checkout_into_cart.py+++ b/saleor/cart/migrations/0007_merge_checkout_into_cart.py@@ -33,4 +33,8 @@ class Migration(migrations.Migration):name='user_email',field=models.EmailField(blank=True, default='', max_length=254),),+ migrations.RemoveField(+ model_name='cart',+ name='checkout_data',+ ),]diff --git a/saleor/cart/models.py b/saleor/cart/models.pyindex ef87be8aa9..ab1457ecf9 100644--- a/saleor/cart/models.py+++ b/saleor/cart/models.py@@ -73,7 +73,6 @@ class Cart(models.Model):voucher = models.ForeignKey('discount.Voucher', null=True, related_name='+',on_delete=models.SET_NULL)- checkout_data = JSONField(null=True, editable=False)total = MoneyField(currency=settings.DEFAULT_CURRENCY, max_digits=12,decimal_places=settings.DEFAULT_DECIMAL_PLACES, default=0)diff --git a/saleor/cart/urls.py b/saleor/cart/urls.pyindex 2416284603..a5e7ab8fb3 100644--- a/saleor/cart/urls.py+++ b/saleor/cart/urls.py@@ -1,10 +1,12 @@-from django.conf.urls import url+from django.conf.urls import include, urlfrom . import views+from .checkout.urls import urlpatterns as checkout_urlsurlpatterns = [url(r'^$', views.index, name='index'),url(r'^update/(?P<variant_id>\d+)/$', views.update, name='update-line'),url(r'^summary/$', views.summary, name='cart-summary'),url(r'^shipping-options/$', views.get_shipping_options,- name='shipping-options')]+ name='shipping-options'),+ url(r'^checkout/', include(checkout_urls))]diff --git a/saleor/checkout/__init__.py b/saleor/checkout/__init__.pydeleted file mode 100644index e69de29bb2..0000000000diff --git a/saleor/checkout/forms.py b/saleor/checkout/forms.pydeleted file mode 100644index 8b1fa72c0a..0000000000--- a/saleor/checkout/forms.py+++ /dev/null@@ -1,18 +0,0 @@-"""Checkout-related forms."""-from django import forms-from django.utils.translation import pgettext_lazy---class CheckoutAddressField(forms.ChoiceField):- """Like a choice field but uses a radio group instead of a dropdown."""-- widget = forms.RadioSelect()---class AnonymousUserShippingForm(forms.Form):- """Additional shipping information form for users who are not logged in."""-- email = forms.EmailField(- required=True, widget=forms.EmailInput(- attrs={'autocomplete': 'shipping email'}),- label=pgettext_lazy('Shipping form field label', 'Email'))diff --git a/saleor/checkout/urls.py b/saleor/checkout/urls.pydeleted file mode 100644index b3480f058e..0000000000--- a/saleor/checkout/urls.py+++ /dev/null@@ -1,16 +0,0 @@-from django.conf.urls import url--from . import views-from ..cart.checkout.views import (- shipping_address_view, shipping_method_view, summary_view)--urlpatterns = [- url(r'^$', views.index_view, name='index'),- url(r'^shipping-address/', shipping_address_view,- name='shipping-address'),- url(r'^shipping-method/', shipping_method_view,- name='shipping-method'),- url(r'^summary/', summary_view, name='summary'),- url(r'^remove_voucher/', views.discount.remove_voucher_view,- name='remove-voucher'),- url(r'^login/', views.login, name='login')]diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pydeleted file mode 100644index 60fae2076f..0000000000--- a/saleor/checkout/utils.py+++ /dev/null@@ -1,72 +0,0 @@-from django.utils.translation import pgettext--from ..cart.utils import (- get_category_variants_and_prices, get_product_variants_and_prices)-from ..discount import VoucherType-from ..discount.models import NotApplicable-from ..discount.utils import (- get_product_or_category_voucher_discount, get_shipping_voucher_discount,- get_value_voucher_discount)---def _get_value_voucher_discount_for_checkout(voucher, checkout):- """Calculate discount value for a voucher of value type."""- return get_value_voucher_discount(voucher, checkout.get_subtotal())---def _get_shipping_voucher_discount_for_checkout(voucher, checkout):- """Calculate discount value for a voucher of shipping type."""- if not checkout.cart.is_shipping_required():- msg = pgettext(- 'Voucher not applicable',- 'Your order does not require shipping.')- raise NotApplicable(msg)- shipping_method = checkout.cart.shipping_method- if not shipping_method:- msg = pgettext(- 'Voucher not applicable',- 'Please select a shipping method first.')- raise NotApplicable(msg)- not_valid_for_country = (- voucher.apply_to and shipping_method.country_code != voucher.apply_to)- if not_valid_for_country:- msg = pgettext(- 'Voucher not applicable',- 'This offer is only valid in %(country)s.')- raise NotApplicable(- msg % {'country': voucher.get_apply_to_display()})- return get_shipping_voucher_discount(- voucher, checkout.get_subtotal(), shipping_method.get_total_price())---def _get_product_or_category_voucher_discount_for_checkout(voucher, checkout):- """Calculate discount value for a voucher of product or category type."""- if voucher.type == VoucherType.PRODUCT:- prices = [- variant_price for _, variant_price in- get_product_variants_and_prices(checkout.cart, voucher.product)]- else:- prices = [- variant_price for _, variant_price in- get_category_variants_and_prices(checkout.cart, voucher.category)]- if not prices:- msg = pgettext(- 'Voucher not applicable',- 'This offer is only valid for selected items.')- raise NotApplicable(msg)- return get_product_or_category_voucher_discount(voucher, prices)---def get_voucher_discount_for_checkout(voucher, checkout):- """Calculate discount value depending on voucher and discount types.-- Raise NotApplicable if voucher of given type cannot be applied.- """- if voucher.type == VoucherType.VALUE:- return _get_value_voucher_discount_for_checkout(voucher, checkout)- if voucher.type == VoucherType.SHIPPING:- return _get_shipping_voucher_discount_for_checkout(voucher, checkout)- if voucher.type in (VoucherType.PRODUCT, VoucherType.CATEGORY):- return _get_product_or_category_voucher_discount_for_checkout(- voucher, checkout)- raise NotImplementedError('Unknown discount type')diff --git a/saleor/checkout/views/__init__.py b/saleor/checkout/views/__init__.pydeleted file mode 100644index a68734cfa7..0000000000--- a/saleor/checkout/views/__init__.py+++ /dev/null@@ -1,25 +0,0 @@-from django.shortcuts import redirect-from django.template.response import TemplateResponse--from .discount import add_voucher_form, validate_voucher-from .validators import validate_cart, validate_is_shipping_required-from ..core import load_checkout-from ...account.forms import LoginForm---@load_checkout-@validate_cart-@validate_is_shipping_required-def index_view(request, cart, checkout):- """Redirect to the initial step of checkout."""- return redirect('checkout:shipping-address')---@load_checkout-@validate_cart-def login(request, cart, checkout):- """Allow the user to log in prior to checkout."""- if request.user.is_authenticated:- return redirect('checkout:index')- form = LoginForm()- return TemplateResponse(request, 'checkout/login.html', {'form': form})diff --git a/saleor/discount/forms.py b/saleor/discount/forms.pyindex 4db214b3f6..2a0b775f98 100644--- a/saleor/discount/forms.py+++ b/saleor/discount/forms.py@@ -4,7 +4,7 @@ from django import formsfrom django.utils.encoding import smart_textfrom django.utils.translation import pgettext_lazy-from ..checkout.utils import get_voucher_discount_for_checkout+from ..cart.checkout.utils import get_voucher_discount_for_checkoutfrom .models import NotApplicable, Voucherdiff --git a/saleor/settings.py b/saleor/settings.pyindex 19e26c74d5..043aae5996 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -188,7 +188,6 @@ INSTALLED_APPS = ['saleor.discount','saleor.product','saleor.cart',- 'saleor.checkout','saleor.core','saleor.graphql','saleor.menu',diff --git a/saleor/urls.py b/saleor/urls.pyindex dce06f973e..52ecbbfb5c 100644--- a/saleor/urls.py+++ b/saleor/urls.py@@ -9,7 +9,6 @@ from graphene_django.views import GraphQLViewfrom .account.urls import urlpatterns as account_urlsfrom .cart.urls import urlpatterns as cart_urls-from .checkout.urls import urlpatterns as checkout_urlsfrom .core.sitemaps import sitemapsfrom .core.urls import urlpatterns as core_urlsfrom .dashboard.urls import urlpatterns as dashboard_urls@@ -35,8 +34,6 @@ non_translatable_urlpatterns = [translatable_urlpatterns = [url(r'^', include(core_urls)),url(r'^cart/', include((cart_urls, 'cart'), namespace='cart')),- url(r'^checkout/',- include((checkout_urls, 'checkout'), namespace='checkout')),url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name='javascript-catalog'),url(r'^order/', include((order_urls, 'order'), namespace='order')),url(r'^page/', include((page_urls, 'page'), namespace='page')),diff --git a/templates/cart/index.html b/templates/cart/index.htmlindex 18f7ac6d08..0048679fe1 100644--- a/templates/cart/index.html+++ b/templates/cart/index.html@@ -77,7 +77,7 @@</div><div class="row"><div class="col-md-12">- <a href="{% url "checkout:login" %}" class="btn primary float-right cart__submit">+ <a href="{% url "cart:checkout-login" %}" class="btn primary float-right cart__submit">{% trans "Checkout" context "Cart primary action" %}</a></div>diff --git a/templates/cart_dropdown.html b/templates/cart_dropdown.htmlindex c966ea9dc7..7ba65d11af 100644--- a/templates/cart_dropdown.html+++ b/templates/cart_dropdown.html@@ -54,7 +54,7 @@<a href="{% url "cart:index" %}" class="btn secondary narrow float-md-right">{% trans "Go to cart" context "Cart dropdown secondary action" %}</a></div><div class="col-md-5">- <a href="{% url "checkout:login" %}" class="btn primary narrow float-md-right">{% trans "Checkout" context "Cart dropdown primary action" %}</a>+ <a href="{% url "cart:checkout-login" %}" class="btn primary narrow float-md-right">{% trans "Checkout" context "Cart dropdown primary action" %}</a></div></div>{% else %}diff --git a/templates/checkout/login.html b/templates/checkout/login.htmlindex d148e8f6b6..75bf833b6f 100644--- a/templates/checkout/login.html+++ b/templates/checkout/login.html@@ -14,7 +14,7 @@data-src="{% static 'images/login-bg.png' %}"data-srcset="{% static 'images/login-bg.png' %} 1x, {% static 'images/login-bg2x.png' %} 2x"><p>- <a href="{% url 'checkout:index' %}" class="btn secondary narrow">+ <a href="{% url 'cart:checkout-index' %}" class="btn secondary narrow">{% trans "Continue" context "Checkout login page new users action" %}</a></p>@@ -22,7 +22,7 @@</div></div><div class="col-12 col-md-6 checkout__login__form">- {% url "checkout:index" as checkout_url %}+ {% url "cart:checkout-index" as checkout_url %}<h3>{% trans "Existing customer? Log in." context "Checkout login form title" %}</h3>{% include "account/partials/login_form.html" with REDIRECT_FIELD_VALUE=checkout_url %}</div>diff --git a/templates/checkout/shipping_method.html b/templates/checkout/shipping_method.htmlindex c2a10ad78c..96363ecf47 100644--- a/templates/checkout/shipping_method.html+++ b/templates/checkout/shipping_method.html@@ -6,7 +6,7 @@{% block forms %}<h3>{% trans "Shipping address" context "Checkout shipping address title" %}</h3>{% format_address cart.shipping_address %}- <p><a href="{% url 'checkout:shipping-address' %}">{% trans "Select other address" %}</a></p>+ <p><a href="{% url 'cart:checkout-shipping-address' %}">{% trans "Select other address" %}</a></p><hr><form method="post" novalidate>{% csrf_token %}diff --git a/templates/checkout/snippets/voucher_form.html b/templates/checkout/snippets/voucher_form.htmlindex 2cd5565f3f..63dccb23c1 100644--- a/templates/checkout/snippets/voucher_form.html+++ b/templates/checkout/snippets/voucher_form.html@@ -4,7 +4,7 @@{% if form %}{% if checkout.discount %}- <form action="{% url "checkout:remove-voucher" %}?next={{ request.path }}"+ <form action="{% url "cart:checkout-remove-voucher" %}?next={{ request.path }}"method="post"class="float-left input-btn">{% csrf_token %}diff --git a/tests/conftest.py b/tests/conftest.pyindex e1515b9262..60a126dd7e 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -18,7 +18,7 @@ from prices import Moneyfrom saleor.account.models import Address, Userfrom saleor.cart import utilsfrom saleor.cart.models import Cart-from saleor.checkout.core import Checkout+from saleor.cart.checkout.core import Checkoutfrom saleor.dashboard.order.utils import fulfill_order_linefrom saleor.discount.models import Sale, Voucherfrom saleor.menu.models import Menu, MenuItemdiff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex 601fe5b420..69e46a3cce 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -5,10 +5,10 @@ from django.contrib.auth.models import AnonymousUserfrom django.urls import reversefrom prices import Money, TaxedMoney+from saleor.cart.checkout import viewsfrom saleor.cart.checkout.forms import NoteForm-from saleor.checkout import views-from saleor.checkout.core import STORAGE_SESSION_KEY, Checkout-from saleor.checkout.utils import get_voucher_discount_for_checkout+from saleor.cart.checkout.utils import get_voucher_discount_for_checkout+from saleor.cart.checkout.core import STORAGE_SESSION_KEY, Checkoutfrom saleor.core.exceptions import InsufficientStockfrom saleor.discount import DiscountValueType, VoucherTypefrom saleor.discount.models import Voucher, NotApplicable@@ -47,12 +47,12 @@ def test_checkout_clear_storage(checkout):Mock(__len__=Mock(return_value=1),is_shipping_required=Mock(return_value=True)),- 302, reverse('checkout:shipping-address')),+ 302, reverse('cart:checkout-shipping-address')),(Mock(__len__=Mock(return_value=1),is_shipping_required=Mock(return_value=False)),- 302, reverse('checkout:summary')),+ 302, reverse('cart:checkout-summary')),(Mock(__len__=Mock(return_value=0),@@ -60,7 +60,7 @@ def test_checkout_clear_storage(checkout):302, reverse('cart:index'))])def test_index_view(checkout, cart, status_code, url, rf, monkeypatch):checkout.cart = cart- request = rf.get('checkout:index', follow=True)+ request = rf.get('cart:checkout-index', follow=True)request.user = checkout.userrequest.session = {STORAGE_SESSION_KEY: checkout.for_storage()}request.discounts = []@@ -222,7 +222,7 @@ def test_shipping_voucher_checkout_discount_not_applicable(def test_product_voucher_checkout_discount_not_applicable(settings, monkeypatch):monkeypatch.setattr(- 'saleor.checkout.utils.get_product_variants_and_prices',+ 'saleor.cart.checkout.utils.get_product_variants_and_prices',lambda cart, product: [])voucher = Voucher(code='unique', type=VoucherType.PRODUCT,@@ -238,7 +238,7 @@ def test_product_voucher_checkout_discount_not_applicable(def test_category_voucher_checkout_discount_not_applicable(settings, monkeypatch):monkeypatch.setattr(- 'saleor.checkout.utils.get_category_variants_and_prices',+ 'saleor.cart.checkout.utils.get_category_variants_and_prices',lambda cart, product: [])voucher = Voucher(code='unique', type=VoucherType.CATEGORY,diff --git a/tests/test_checkout_integration.py b/tests/test_checkout_integration.pyindex 197ae7ed16..523bd013a4 100644--- a/tests/test_checkout_integration.py+++ b/tests/test_checkout_integration.py@@ -13,13 +13,13 @@ def test_checkout_flow(mock_send_confirmation, request_cart_with_item, client,shipping_method):# Enter checkout- checkout_index = client.get(reverse('checkout:index'), follow=True)+ checkout_index = client.get(reverse('cart:checkout-index'), follow=True)# Checkout index redirects directly to shipping address stepshipping_address = client.get(checkout_index.request['PATH_INFO'])# Enter shipping address datashipping_data = {- 'email': '[email protected]',+ 'user_email': '[email protected]','first_name': 'John','last_name': 'Doe','street_address_1': 'Aleje Jerozolimskie 2',@@ -88,7 +88,7 @@ def test_checkout_flow_authenticated_user(# Enter checkout# Checkout index redirects directly to shipping address stepshipping_address = authorized_client.get(- reverse('checkout:index'), follow=True)+ reverse('cart:checkout-index'), follow=True)# Enter shipping address datashipping_data = {'address': customer_user.default_billing_address.pk}@@ -145,9 +145,9 @@ def test_address_without_shipping(request_cart_with_item, client):product_type.is_shipping_required = Falseproduct_type.save()- response = client.get(reverse('checkout:shipping-address'))+ response = client.get(reverse('cart:checkout-shipping-address'))assert response.status_code == 302- assert get_redirect_location(response) == reverse('checkout:summary')+ assert get_redirect_location(response) == reverse('cart:checkout-summary')def test_shipping_method_without_shipping(@@ -157,32 +157,32 @@ def test_shipping_method_without_shipping(product_type.is_shipping_required = Falseproduct_type.save()- response = client.get(reverse('checkout:shipping-method'))+ response = client.get(reverse('cart:checkout-shipping-method'))assert response.status_code == 302- assert get_redirect_location(response) == reverse('checkout:summary')+ assert get_redirect_location(response) == reverse('cart:checkout-summary')def test_shipping_method_without_address(request_cart_with_item, client):- response = client.get(reverse('checkout:shipping-method'))+ response = client.get(reverse('cart:checkout-shipping-method'))assert response.status_code == 302assert (get_redirect_location(response) ==- reverse('checkout:shipping-address'))+ reverse('cart:checkout-shipping-address'))def test_summary_without_address(request_cart_with_item, client):- response = client.get(reverse('checkout:summary'))+ response = client.get(reverse('cart:checkout-summary'))assert response.status_code == 302assert (- get_redirect_location(response) == reverse('checkout:shipping-method'))+ get_redirect_location(response) == reverse('cart:checkout-shipping-method'))def test_summary_without_shipping_method(request_cart_with_item, client, monkeypatch):- response = client.get(reverse('checkout:summary'))+ response = client.get(reverse('cart:checkout-summary'))assert response.status_code == 302assert (- get_redirect_location(response) == reverse('checkout:shipping-method'))+ get_redirect_location(response) == reverse('cart:checkout-shipping-method'))def test_email_is_saved_in_order(@@ -195,7 +195,7 @@ def test_email_is_saved_in_order(# Enter checkout# Checkout index redirects directly to shipping address stepshipping_address = authorized_client.get(- reverse('checkout:index'), follow=True)+ reverse('cart:checkout-index'), follow=True)# Enter shipping address datashipping_data = {'address': customer_user.default_billing_address.pk}@@ -226,13 +226,13 @@ def test_voucher_invalid(voucher.usage_limit = 3voucher.save()# Enter checkout- checkout_index = client.get(reverse('checkout:index'), follow=True)+ checkout_index = client.get(reverse('cart:checkout-index'), follow=True)# Checkout index redirects directly to shipping address stepshipping_address = client.get(checkout_index.request['PATH_INFO'])# Enter shipping address datashipping_data = {- 'email': '[email protected]',+ 'user_email': '[email protected]','first_name': 'John','last_name': 'Doe','street_address_1': 'Aleje Jerozolimskie 2',@@ -265,7 +265,7 @@ def test_voucher_invalid(voucher.used = 3voucher.save()address_data = {'address': 'shipping_address'}- assert url == reverse('checkout:summary')+ assert url == reverse('cart:checkout-summary')summary_response = client.post(url, data=address_data, follow=True)assert summary_response.context['checkout'].voucher_code is None@@ -276,7 +276,7 @@ def test_voucher_invalid(def test_voucher_code_invalid(client, request_cart_with_item, shipping_method):# Enter checkout- checkout_index = client.get(reverse('checkout:index'), follow=True)+ checkout_index = client.get(reverse('cart:checkout-index'), follow=True)# Checkout index redirects directly to shipping address stepshipping_address = client.get(checkout_index.request['PATH_INFO'])@@ -319,7 +319,7 @@ def test_voucher_code_invalid(def test_remove_voucher(client, request_cart_with_item, shipping_method, voucher):# Enter checkout- checkout_index = client.get(reverse('checkout:index'), follow=True)+ checkout_index = client.get(reverse('cart:checkout-index'), follow=True)# Checkout index redirects directly to shipping address stepshipping_address = client.get(checkout_index.request['PATH_INFO'])@@ -357,7 +357,7 @@ def test_remove_voucher(assert voucher_response.context['checkout'].voucher_code is not None# Remove voucher from checkoutvoucher_response = client.post(- reverse('checkout:remove-voucher'), follow=True, HTTP_REFERER=url)+ reverse('cart:checkout-remove-voucher'), follow=True, HTTP_REFERER=url)assert voucher_response.status_code == 200assert voucher_response.context['checkout'].voucher_code is None@@ -377,7 +377,7 @@ def test_language_is_saved_in_order(# Enter checkout# Checkout index redirects directly to shipping address stepshipping_address = authorized_client.get(- reverse('checkout:index'), follow=True,+ reverse('cart:checkout-index'), follow=True,HTTP_ACCEPT_LANGUAGE=user_language)# Enter shipping address datadiff --git a/tests/test_discounts.py b/tests/test_discounts.pyindex c918e0ac37..cf4c2ed43e 100644--- a/tests/test_discounts.py+++ b/tests/test_discounts.py@@ -5,7 +5,7 @@ import pytestfrom freezegun import freeze_timefrom prices import Money, TaxedMoney-from saleor.checkout.utils import get_voucher_discount_for_checkout+from saleor.cart.checkout.utils import get_voucher_discount_for_checkoutfrom saleor.discount import (DiscountValueType, VoucherApplyToProduct, VoucherType)from saleor.discount.forms import CheckoutDiscountForm@@ -159,7 +159,7 @@ def test_products_voucher_checkout_discount_not(settings, monkeypatch, prices, discount_value, discount_type, apply_to,expected_value):monkeypatch.setattr(- 'saleor.checkout.utils.get_product_variants_and_prices',+ 'saleor.cart.checkout.utils.get_product_variants_and_prices',lambda cart, product: ((None, TaxedMoney(net=Money(price, 'USD'), gross=Money(price, 'USD')))