Skip to content

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

Use CountryForm in cart view to choose information about delivery prices

Mira Szewczyk41067a2486dd
diff --git a/saleor/cart/views.py b/saleor/cart/views.py
index 6e20285115..ae3e6c826c 100644
--- a/saleor/cart/views.py
+++ b/saleor/cart/views.py
@@ -7,11 +7,10 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.template.response import TemplateResponse
from . import decorators
-from ..core.utils import to_local_currency
+from ..core.utils import to_local_currency, get_default_country
from ..product.models import ProductVariant
-from ..shipping.models import COUNTRY_CODE_CHOICES
from ..shipping.utils import assign_shipment_to_country
-from .forms import ReplaceCartLineForm
+from .forms import ReplaceCartLineForm, CountryForm
from .models import Cart
from .utils import check_product_availability_and_warn
@@ -39,13 +38,17 @@ def index(request, cart):
cart_total = cart.get_total(discounts=discounts)
local_cart_total = to_local_currency(cart_total, request.currency)
+ default_country = get_default_country(request)
+ country_form = CountryForm(request.POST or None,
+ initial={'country': default_country})
+
return TemplateResponse(
request, 'cart/index.html',
{
'cart_lines': cart_lines,
'cart_total': cart_total,
'local_cart_total': local_cart_total,
- 'country_choices': COUNTRY_CODE_CHOICES,
+ 'country_form': country_form,
'shipment_by_country': shipment_by_country})