fix: auto pick country in 1 country regions
This commit is contained in:
@@ -135,9 +135,11 @@ class KlarnaProviderService extends PaymentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check if country matches ISO
|
// TODO: Check if country matches ISO
|
||||||
if (!_.isEmpty(cart.billing_address) && cart.billing_address.country) {
|
if (
|
||||||
order.purchase_country =
|
!_.isEmpty(cart.shipping_address) &&
|
||||||
cart.shipping_address.country_code || cart.billing_address.country_code
|
cart.shipping_address.country_code
|
||||||
|
) {
|
||||||
|
order.purchase_country = cart.shipping_address.country_code
|
||||||
} else {
|
} else {
|
||||||
// Defaults to Sweden
|
// Defaults to Sweden
|
||||||
order.purchase_country = "SE"
|
order.purchase_country = "SE"
|
||||||
|
|||||||
@@ -1135,10 +1135,15 @@ class CartService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the country code of a shipping address is set we need to clear it
|
// 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) {
|
if (!_.isEmpty(shippingAddress) && shippingAddress.country_code) {
|
||||||
shippingAddress.country_code =
|
shippingAddress.country_code = ""
|
||||||
region.countries.length === 1 ? region.countries[0] : ""
|
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
|
update.shipping_address = shippingAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user