Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Change logic of filtering shipping methods
Mira Szewczykd81a26b8fa0c
diff --git a/saleor/cart/forms.py b/saleor/cart/forms.pyindex 46de883f29..9a58399af3 100644--- a/saleor/cart/forms.py+++ b/saleor/cart/forms.py@@ -118,7 +118,9 @@ class ReplaceCartLineForm(AddToCartForm):class CountryForm(forms.Form):+country = forms.ChoiceField(choices=COUNTRY_CODE_CHOICES, label='')+def get_shipment_options(self):code = self.cleaned_data['country']return get_shipment_options(code)diff --git a/saleor/shipping/utils.py b/saleor/shipping/utils.pyindex d4099f731b..45e0146ead 100644--- a/saleor/shipping/utils.py+++ b/saleor/shipping/utils.py@@ -3,7 +3,9 @@ from .models import ShippingMethodCountrydef get_shipment_options(country_code):- return ShippingMethodCountry.objects.select_related(- 'shipping_method').filter(- Q(country_code=country_code) | Q(country_code='')).order_by(- 'price').values('price', 'shipping_method__name')+ shipping_methods_qs = ShippingMethodCountry.objects.select_related(+ 'shipping_method').values('price', 'shipping_method__name')+ shipping_methods = shipping_methods_qs.filter(country_code=country_code)+ if not shipping_methods.exists():+ shipping_methods = shipping_methods_qs.filter(country_code='')+ return shipping_methods