fix: auto pick country in 1 country regions

This commit is contained in:
Sebastian Rindom
2020-08-31 11:19:04 +02:00
parent ec2728bbd5
commit d11eb8fa65
2 changed files with 13 additions and 6 deletions
+8 -3
View File
@@ -1135,10 +1135,15 @@ class CartService extends BaseService {
}
// If the country code of a shipping address is set we need to clear it
let shippingAddress = cart.shipping_address
let shippingAddress = cart.shipping_address || {}
if (!_.isEmpty(shippingAddress) && shippingAddress.country_code) {
shippingAddress.country_code =
region.countries.length === 1 ? region.countries[0] : ""
shippingAddress.country_code = ""
update.shipping_address = shippingAddress
}
// If there is only one country in the region preset it
if (region.countries.length === 1) {
shippingAddress.country_code = region.countries[0]
update.shipping_address = shippingAddress
}