Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Save shipping method in Cart during checkout
Anna Siwikc06a61dfb262
diff --git a/saleor/cart/checkout/forms.py b/saleor/cart/checkout/forms.pyindex a1ab33fc87..930c0378f8 100644--- a/saleor/cart/checkout/forms.py+++ b/saleor/cart/checkout/forms.py@@ -1,7 +1,13 @@from django import forms+from django.utils.safestring import mark_safefrom django.utils.translation import pgettext_lazy+from ...cart.models import Cart+from ...core.utils import format_money+from ...core.utils.taxes import display_gross_pricesfrom ...checkout.forms import CheckoutAddressField+from ...shipping.models import ShippingMethodCountry+from ...shipping.utils import get_taxed_shipping_priceclass AnonymousUserShippingForm(forms.Form):@@ -30,3 +36,57 @@ class AddressChoiceForm(forms.Form):super().__init__(*args, **kwargs)address_choices = [(address.id, str(address)) for address in addresses]self.fields['address'].choices = self.CHOICES + address_choices+++# FIXME: why is this called a country choice field?+class ShippingCountryChoiceField(forms.ModelChoiceField):+ """Shipping method country choice field.++ Uses a radio group instead of a dropdown and includes estimated shipping+ prices.+ """+ taxes = None+ widget = forms.RadioSelect()++ def label_from_instance(self, obj):+ """Return a friendly label for the shipping method."""+ price = get_taxed_shipping_price(obj.price, self.taxes)+ if display_gross_prices():+ price = price.gross+ else:+ price = price.net+ price_html = format_money(price)+ label = mark_safe('%s %s' % (obj.shipping_method, price_html))+ return label+++class CartShippingMethodForm(forms.ModelForm):+ """Cart shipping method form."""++ shipping_method = ShippingCountryChoiceField(+ queryset=ShippingMethodCountry.objects.select_related(+ 'shipping_method').order_by('price').all(),+ label=pgettext_lazy(+ 'Shipping method form field label', 'Shipping method'),+ required=True)++ class Meta:+ model = Cart+ fields = ['shipping_method']++ def __init__(self, *args, **kwargs):+ taxes = kwargs.pop('taxes')+ super().__init__(*args, **kwargs)+ method_field = self.fields['shipping_method']+ method_field.taxes = taxes++ country_code = self.instance.shipping_address.country.code+ if country_code:+ queryset = method_field.queryset+ method_field.queryset = queryset.unique_for_country_code(+ country_code)++ if self.initial.get('shipping_method') is None:+ self.initial['shipping_method'] = method_field.queryset.first()++ method_field.empty_label = Nonediff --git a/saleor/cart/checkout/utils.py b/saleor/cart/checkout/utils.pyindex a1362c0796..9d16d46bb5 100644--- a/saleor/cart/checkout/utils.py+++ b/saleor/cart/checkout/utils.py@@ -15,3 +15,14 @@ def save_shipping_address_in_cart(cart, address):cart.shipping_address.delete()cart.shipping_address = addresscart.save()+++def get_checkout_data(cart, discounts, taxes):+ """Data shared between views in checkout process."""+ lines = [+ (line, line.get_total(discounts, taxes)) for line in cart.lines.all()]+ subtotal = cart.get_total(discounts, taxes)+ return {+ 'cart': cart,+ 'cart_lines': lines,+ 'cart_subtotal': subtotal}diff --git a/saleor/cart/checkout/views/__init__.py b/saleor/cart/checkout/views/__init__.pyindex e69de29bb2..0489f93c09 100644--- a/saleor/cart/checkout/views/__init__.py+++ b/saleor/cart/checkout/views/__init__.py@@ -0,0 +1,49 @@+from django.shortcuts import redirect+from django.template.response import TemplateResponse++from ....checkout.core import load_checkout+from ....checkout.views import (+ add_voucher_form, validate_cart, validate_is_shipping_required,+ validate_shipping_address, validate_voucher)+from ..forms import CartShippingMethodForm+from ..utils import get_checkout_data+from .shipping import (+ anonymous_user_shipping_address_view, user_shipping_address_view)+++@load_checkout+@validate_voucher+@validate_cart+@validate_is_shipping_required+@add_voucher_form+def shipping_address_view(request, cart, checkout):+ """Display the correct shipping address step."""+ if request.user.is_authenticated:+ return user_shipping_address_view(request, cart, checkout)+ return anonymous_user_shipping_address_view(request, cart, checkout)+++@load_checkout+@validate_voucher+@validate_cart+@validate_is_shipping_required+@validate_shipping_address+@add_voucher_form+def shipping_method_view(request, cart, checkout):+ """Display the shipping method selection step."""+ taxes = checkout.get_taxes()+ shipping_method_form = CartShippingMethodForm(+ request.POST or None, taxes=taxes, instance=cart,+ initial={'shipping_method': cart.shipping_method})++ if shipping_method_form.is_valid():+ checkout.shipping_method = (+ shipping_method_form.cleaned_data['shipping_method'])+ shipping_method_form.save()+ return redirect('checkout:summary')++ ctx = get_checkout_data(cart, request.discounts, taxes)+ ctx.update({+ 'checkout': checkout,+ 'shipping_method_form': shipping_method_form})+ return TemplateResponse(request, 'checkout/shipping_method.html', ctx)diff --git a/saleor/cart/checkout/views/shipping.py b/saleor/cart/checkout/views/shipping.pyindex 9642aebcee..515fd61b75 100644--- a/saleor/cart/checkout/views/shipping.py+++ b/saleor/cart/checkout/views/shipping.py@@ -3,9 +3,8 @@ from django.template.response import TemplateResponsefrom ....account.forms import get_address_formfrom ....account.models import Address-from ....checkout.utils import get_cart_datafrom ..forms import AddressChoiceForm, AnonymousUserShippingForm-from ..utils import save_shipping_address_in_cart+from ..utils import get_checkout_data, save_shipping_address_in_cartdef anonymous_user_shipping_address_view(request, cart, checkout):@@ -25,7 +24,7 @@ def anonymous_user_shipping_address_view(request, cart, checkout):save_shipping_address_in_cart(cart, address)return redirect('checkout:shipping-method')- ctx = get_cart_data(cart, request.discounts, checkout.get_taxes())+ ctx = get_checkout_data(cart, request.discounts, checkout.get_taxes())ctx.update({'address_form': address_form,'checkout': checkout,@@ -80,7 +79,7 @@ def user_shipping_address_view(request, cart, checkout):save_shipping_address_in_cart(cart, address)return redirect('checkout:shipping-method')- ctx = get_cart_data(cart, request.discounts, checkout.get_taxes())+ ctx = get_checkout_data(cart, request.discounts, checkout.get_taxes())ctx.update({'additional_addresses': additional_addresses,'address_form': address_form,diff --git a/saleor/cart/migrations/0007_cart_shipping_address.py b/saleor/cart/migrations/0007_merge_checkout_into_cart.pysimilarity index 58%rename from saleor/cart/migrations/0007_cart_shipping_address.pyrename to saleor/cart/migrations/0007_merge_checkout_into_cart.pyindex 5f0ed61e5a..88bb4cfa6d 100644--- a/saleor/cart/migrations/0007_cart_shipping_address.py+++ b/saleor/cart/migrations/0007_merge_checkout_into_cart.py@@ -1,4 +1,4 @@-# Generated by Django 2.0.3 on 2018-05-09 14:01+# Generated by Django 2.0.3 on 2018-05-21 12:00from django.db import migrations, modelsimport django.db.models.deletion@@ -8,6 +8,7 @@ class Migration(migrations.Migration):dependencies = [('account', '0018_auto_20180426_0641'),+ ('shipping', '0008_auto_20180108_0814'),('cart', '0006_auto_20180221_0825'),]@@ -17,4 +18,9 @@ class Migration(migrations.Migration):name='shipping_address',field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='account.Address'),),+ migrations.AddField(+ model_name='cart',+ name='shipping_method',+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='carts', to='shipping.ShippingMethodCountry'),+ ),]diff --git a/saleor/cart/models.py b/saleor/cart/models.pyindex 62bbf22501..4c4efe9f54 100644--- a/saleor/cart/models.py+++ b/saleor/cart/models.py@@ -14,6 +14,7 @@ from prices import sum as sum_pricesfrom . import CartStatus, loggerfrom ..account.models import Address+from ..shipping.models import ShippingMethodCountryCENTS = Decimal('0.01')SimpleCart = namedtuple('SimpleCart', ('quantity', 'total', 'token'))@@ -81,6 +82,9 @@ class Cart(models.Model):shipping_address = models.ForeignKey(Address, related_name='+', editable=False, null=True,on_delete=models.SET_NULL)+ shipping_method = models.ForeignKey(+ ShippingMethodCountry, blank=True, null=True, related_name='carts',+ on_delete=models.SET_NULL)objects = CartQueryset.as_manager()diff --git a/saleor/checkout/core.py b/saleor/checkout/core.pyindex 2ece77f969..cc3a43d185 100644--- a/saleor/checkout/core.py+++ b/saleor/checkout/core.py@@ -131,7 +131,7 @@ class Checkout:@propertydef shipping_price(self):- shipping_method = self.shipping_method+ shipping_method = self.cart.shipping_methodreturn (shipping_method.get_total_price(self.get_taxes())if shipping_method else ZERO_TAXED_MONEY)@@ -273,15 +273,20 @@ class Checkout:self._add_to_user_address_book(self.billing_address, is_billing=True)- shipping_method_name = (- smart_text(self.shipping_method) if self.is_shipping_required- else None)+ if self.is_shipping_required:+ shipping_method = self.cart.shipping_method+ shipping_method_name = smart_text(shipping_method)+ else:+ shipping_method = None+ shipping_method_name = None+order_data = {'language_code': get_language(),'billing_address': billing_address,'shipping_address': shipping_address,'tracking_client_id': self.tracking_code,'shipping_price': self.shipping_price,+ 'shipping_method': shipping_method,'shipping_method_name': shipping_method_name,'total': self.get_total()}@@ -350,7 +355,7 @@ class Checkout:def get_total(self):"""Calculate order total with shipping and discount amount."""total = self.get_subtotal()- if self.shipping_method and self.is_shipping_required:+ if self.cart.shipping_method and self.is_shipping_required:total += self.shipping_priceif self.discount:total -= self.discountdiff --git a/saleor/checkout/forms.py b/saleor/checkout/forms.pyindex 479f0cf8a7..61ad01b3e6 100644--- a/saleor/checkout/forms.py+++ b/saleor/checkout/forms.py@@ -1,13 +1,7 @@"""Checkout-related forms."""from django import forms-from django.utils.safestring import mark_safefrom django.utils.translation import pgettext_lazy-from ..core.utils import format_money-from ..core.utils.taxes import display_gross_prices-from ..shipping.models import ShippingMethodCountry-from ..shipping.utils import get_taxed_shipping_price-class CheckoutAddressField(forms.ChoiceField):"""Like a choice field but uses a radio group instead of a dropdown."""@@ -58,60 +52,6 @@ class BillingWithoutShippingAddressForm(ShippingAddressesForm):"""-# FIXME: why is this called a country choice field?-class ShippingCountryChoiceField(forms.ModelChoiceField):- """Shipping method choice field.-- Uses a radio group instead of a dropdown and includes estimated shipping- prices.- """-- widget = forms.RadioSelect()-- def __init__(self, *args, **kwargs):- super().__init__(*args, **kwargs)- self.taxes = None-- def label_from_instance(self, obj):- """Return a friendly label for the shipping method."""- price = get_taxed_shipping_price(obj.price, self.taxes)- if display_gross_prices():- price = price.gross- else:- price = price.net- price_html = format_money(price)- label = mark_safe('%s %s' % (obj.shipping_method, price_html))- return label-- def set_taxes(self, taxes):- self.taxes = taxes---class ShippingMethodForm(forms.Form):- """Shipping method form."""-- method = ShippingCountryChoiceField(- queryset=ShippingMethodCountry.objects.select_related(- 'shipping_method').order_by('price').all(),- label=pgettext_lazy(- 'Shipping method form field label', 'Shipping method'),- required=True)-- def __init__(self, country_code, taxes, *args, **kwargs):- super().__init__(*args, **kwargs)- method_field = self.fields['method']- method_field.set_taxes(taxes)- if country_code:- queryset = method_field.queryset- method_field.queryset = queryset.unique_for_country_code(- country_code)-- if self.initial.get('method') is None:- self.initial['method'] = method_field.queryset.first()-- method_field.empty_label = None--class AnonymousUserShippingForm(forms.Form):"""Additional shipping information form for users who are not logged in."""diff --git a/saleor/checkout/urls.py b/saleor/checkout/urls.pyindex 849ef982a5..0c41e8274c 100644--- a/saleor/checkout/urls.py+++ b/saleor/checkout/urls.py@@ -1,12 +1,13 @@from django.conf.urls import urlfrom . import views+from ..cart.checkout.views import shipping_address_view, shipping_method_viewurlpatterns = [url(r'^$', views.index_view, name='index'),- url(r'^shipping-address/', views.shipping_address_view,+ url(r'^shipping-address/', shipping_address_view,name='shipping-address'),- url(r'^shipping-method/', views.shipping_method_view,+ url(r'^shipping-method/', shipping_method_view,name='shipping-method'),url(r'^summary/', views.summary_view, name='summary'),url(r'^remove_voucher/', views.discount.remove_voucher_view,diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 14dbc17b15..e825f6af52 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -21,7 +21,7 @@ def _get_shipping_voucher_discount_for_checkout(voucher, checkout):'Voucher not applicable','Your order does not require shipping.')raise NotApplicable(msg)- shipping_method = checkout.shipping_method+ shipping_method = checkout.cart.shipping_methodif not shipping_method:msg = pgettext('Voucher not applicable',@@ -70,14 +70,3 @@ def get_voucher_discount_for_checkout(voucher, checkout):return _get_product_or_category_voucher_discount_for_checkout(voucher, checkout)raise NotImplementedError('Unknown discount type')---def get_cart_data(cart, discounts, taxes):- """Prepare cart data displayed in checkout process."""- lines = [- (line, line.get_total(discounts, taxes)) for line in cart.lines.all()]- subtotal = cart.get_total(discounts, taxes)- return {- 'cart': cart,- 'cart_lines': lines,- 'cart_subtotal': subtotal}diff --git a/saleor/checkout/views/__init__.py b/saleor/checkout/views/__init__.pyindex c8fd10af27..53497076c8 100644--- a/saleor/checkout/views/__init__.py+++ b/saleor/checkout/views/__init__.py@@ -9,11 +9,7 @@ from .validators import (validate_cart, validate_shipping_address,validate_shipping_method, validate_is_shipping_required)from ..core import load_checkout-from ..forms import ShippingMethodForm-from ..utils import get_cart_datafrom ...account.forms import LoginForm-from ...cart.checkout.views.shipping import (- anonymous_user_shipping_address_view, user_shipping_address_view)@load_checkout@@ -24,42 +20,6 @@ def index_view(request, cart, checkout):return redirect('checkout:shipping-address')-@load_checkout-@validate_voucher-@validate_cart-@validate_is_shipping_required-@add_voucher_form-def shipping_address_view(request, cart, checkout):- """Display the correct shipping address step."""- if request.user.is_authenticated:- return user_shipping_address_view(request, cart, checkout)- return anonymous_user_shipping_address_view(request, cart, checkout)---@load_checkout-@validate_voucher-@validate_cart-@validate_is_shipping_required-@validate_shipping_address-@add_voucher_form-def shipping_method_view(request, cart, checkout):- """Display the shipping method selection step."""- country_code = cart.shipping_address.country.code- shipping_method_form = ShippingMethodForm(- country_code, request.taxes, request.POST or None,- initial={'method': checkout.shipping_method})-- if shipping_method_form.is_valid():- checkout.shipping_method = shipping_method_form.cleaned_data['method']- return redirect('checkout:summary')-- ctx = get_cart_data(cart, request.discounts, checkout.get_taxes())- ctx.update({- 'checkout': checkout,- 'shipping_method_form': shipping_method_form})- return TemplateResponse(request, 'checkout/shipping_method.html', ctx)--@load_checkout@validate_voucher@validate_cartdiff --git a/saleor/checkout/views/summary.py b/saleor/checkout/views/summary.pyindex 272bf3bad4..57b648558a 100644--- a/saleor/checkout/views/summary.py+++ b/saleor/checkout/views/summary.py@@ -5,7 +5,7 @@ from django.utils.translation import pgettext, pgettext_lazyfrom ...account.forms import get_address_formfrom ...account.models import Address-from ...checkout.utils import get_cart_data+from ...cart.checkout.utils import get_checkout_datafrom ...core.exceptions import InsufficientStockfrom ...order.emails import send_order_confirmationfrom ..forms import (@@ -109,7 +109,7 @@ def summary_with_shipping_view(request, cart, checkout):checkout.billing_address = addressreturn handle_order_placement(request, checkout)- ctx = get_cart_data(cart, request.discounts, checkout.get_taxes())+ ctx = get_checkout_data(cart, request.discounts, checkout.get_taxes())ctx.update({'additional_addresses': additional_addresses,'address_form': address_form,@@ -143,7 +143,7 @@ def anonymous_summary_without_shipping(request, cart, checkout):checkout.billing_address = address_form.instancereturn handle_order_placement(request, checkout)- ctx = get_cart_data(cart, request.discounts, checkout.get_taxes())+ ctx = get_checkout_data(cart, request.discounts, checkout.get_taxes())ctx.update({'address_form': address_form,'checkout': checkout,@@ -196,7 +196,7 @@ def summary_without_shipping(request, cart, checkout):checkout.billing_address = address_form.instancereturn handle_order_placement(request, checkout)- ctx = get_cart_data(cart, request.discounts, checkout.get_taxes())+ ctx = get_checkout_data(cart, request.discounts, checkout.get_taxes())ctx.update({'additional_addresses': user_addresses,'address_form': address_form,diff --git a/saleor/checkout/views/validators.py b/saleor/checkout/views/validators.pyindex b5e12b8301..ed45d519a4 100644--- a/saleor/checkout/views/validators.py+++ b/saleor/checkout/views/validators.py@@ -51,7 +51,7 @@ def validate_shipping_method(view):"""@wraps(view)def func(request, cart, checkout):- if checkout.shipping_method is None:+ if checkout.cart.shipping_method is None:return redirect('checkout:shipping-method')return view(request, cart, checkout)return funcdiff --git a/templates/checkout/details.html b/templates/checkout/details.htmlindex ee8bca7604..8a5076bb42 100644--- a/templates/checkout/details.html+++ b/templates/checkout/details.html@@ -62,7 +62,7 @@</div><div class="col-4"><p class="float-right">- {% if checkout.shipping_method %}+ {% if cart.shipping_method %}{% price checkout.shipping_price %}{% else %}—diff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex 368da65df6..979ab75d94 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -49,45 +49,6 @@ def test_checkout_is_shipping_required(checkout):assert checkout.is_shipping_required is True[email protected]('shipping_address, shipping_method, value', [- (- Mock(country=Mock(code='PL')),- Mock(- country_code='PL',- __eq__=lambda n, o: n.country_code == o.country_code),- Mock(country_code='PL')),- (Mock(country=Mock(code='DE')), Mock(country_code='PL'), None),- (None, Mock(country_code='PL'), None)])-def test_checkout_shipping_method(- checkout, shipping_address, shipping_method, value, monkeypatch):- queryset = Mock(get=Mock(return_value=shipping_method))- monkeypatch.setattr(checkout.cart, 'shipping_address', shipping_address)- monkeypatch.setattr(- 'saleor.checkout.core.ShippingMethodCountry.objects', queryset)- checkout.storage['shipping_method_country_id'] = 1- assert checkout._shipping_method is None- assert checkout.shipping_method == value- assert checkout._shipping_method == value---def test_checkout_shipping_does_not_exists(monkeypatch, checkout):- queryset = Mock(get=Mock(side_effect=ShippingMethodCountry.DoesNotExist))- monkeypatch.setattr(- 'saleor.checkout.core.ShippingMethodCountry.objects', queryset)- checkout.storage['shipping_method_country_id'] = 1- assert checkout.shipping_method is None---def test_checkout_shipping_method_setter(checkout):- assert checkout.modified is False- assert checkout._shipping_method is None- shipping_method = Mock(id=1)- checkout.shipping_method = shipping_method- assert checkout._shipping_method == shipping_method- assert checkout.modified is True- assert checkout.storage['shipping_method_country_id'] == 1--@pytest.mark.parametrize('user, address', [(AnonymousUser(), None),(@@ -155,8 +116,9 @@ def test_checkout_create_order_insufficient_stock(def test_checkout_taxes(checkout_with_items, shipping_method, vatlayer):checkout_with_items.taxes = vatlayer- method = shipping_method.price_per_country.get()- checkout_with_items.shipping_method = method+ cart = checkout_with_items.cart+ cart.shipping_method = shipping_method.price_per_country.get()+ cart.save()assert checkout_with_items.shipping_price == TaxedMoney(net=Money('8.13', 'USD'), gross=Money(10, 'USD'))subtotal = checkout_with_items.cart.get_total(taxes=vatlayer)@@ -228,10 +190,12 @@ def test_shipping_voucher_checkout_discount(net=Money(shipping_cost, 'USD'), gross=Money(shipping_cost, 'USD'))checkout = Mock(get_subtotal=Mock(return_value=subtotal),- is_shipping_required=True, shipping_method=Mock(- price=Money(shipping_cost, 'USD'),- country_code=shipping_country_code,- get_total_price=Mock(return_value=shipping_total)))+ is_shipping_required=True,+ cart=Mock(+ shipping_method=Mock(+ price=Money(shipping_cost, 'USD'),+ country_code=shipping_country_code,+ get_total_price=Mock(return_value=shipping_total))))voucher = Voucher(code='unique', type=VoucherType.SHIPPING,discount_value_type=discount_type,@@ -263,7 +227,7 @@ def test_shipping_voucher_checkout_discount_not_applicable(subtotal_price = TaxedMoney(net=subtotal, gross=subtotal)checkout = Mock(is_shipping_required=is_shipping_required,- shipping_method=shipping_method,+ cart=Mock(shipping_method=shipping_method),get_subtotal=Mock(return_value=subtotal_price))voucher = Voucher(code='unique', type=VoucherType.SHIPPING,diff --git a/tests/test_checkout_integration.py b/tests/test_checkout_integration.pyindex d4ceb9eecc..b04fd28cae 100644--- a/tests/test_checkout_integration.py+++ b/tests/test_checkout_integration.py@@ -38,7 +38,7 @@ def test_checkout_flow(# Redirect to summary after shipping method selectionshipping_method_data = {- 'method': shipping_method.price_per_country.first().pk}+ 'shipping_method': shipping_method.price_per_country.first().pk}shipping_method_response = client.post(shipping_method_page.request['PATH_INFO'], data=shipping_method_data,follow=True)@@ -97,7 +97,7 @@ def test_checkout_flow_authenticated_user(# Select shipping methodshipping_method_data = {- 'method': shipping_method.price_per_country.first().pk}+ 'shipping_method': shipping_method.price_per_country.first().pk}shipping_method_response = authorized_client.post(shipping_method_page.request['PATH_INFO'], data=shipping_method_data,follow=True)@@ -204,7 +204,7 @@ def test_email_is_saved_in_order(# Select shipping methodshipping_method_data = {- 'method': shipping_method.price_per_country.first().pk}+ 'shipping_method': shipping_method.price_per_country.first().pk}shipping_method_response = authorized_client.post(shipping_method_page.request['PATH_INFO'], data=shipping_method_data,follow=True)@@ -250,7 +250,7 @@ def test_voucher_invalid(# Redirect to summary after shipping method selectionshipping_method_data = {- 'method': shipping_method.price_per_country.first().pk}+ 'shipping_method': shipping_method.price_per_country.first().pk}shipping_method_response = client.post(shipping_method_page.request['PATH_INFO'], data=shipping_method_data,follow=True)@@ -388,7 +388,7 @@ def test_language_is_saved_in_order(# Select shipping methodshipping_method_data = {- 'method': shipping_method.price_per_country.first().pk}+ 'shipping_method': shipping_method.price_per_country.first().pk}shipping_method_response = authorized_client.post(shipping_method_page.request['PATH_INFO'], data=shipping_method_data,follow=True, HTTP_ACCEPT_LANGUAGE=user_language)