SelectBillingAddress method exception

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
nopCommerce version: 4.1

In SelectBillingAddress method of checkout controller we face with an exception if address.Country is null. The code which cause an exception is:

if (_shippingSettings.ShipToSameAddress && shipToSameAddress && _shoppingCartService.ShoppingCartRequiresShipping(cart) && address.Country.AllowsShipping)


We think that checking for address.Country != null is missing.

We submit an issue for this bug here.
5 years ago
resanehlab wrote:
We think that checking for address.Country != null is missing.

Thanks a lot! Actually it can be null in some cases. I think we should also check whether "Country" address field is enabled. And when enabled, we should make null validation
5 years ago
Thanks, that's true. Also seems this can cause some exceptions in FindAddress method of address service when a.CountryId is null but countryId has value.

((a.CountryId == null && countryId == null) || a.CountryId.Value == countryId.Value)


This also happens for StateProvince.

Regards
5 years ago
Done. Please see this commit for more details.
5 years ago
Thanks, but there are some issues yet. Actually now if country disabled then ship to the same address functionality doesn't work and this is make no sense. I commented on your commit and specified more details.
5 years ago
@resanehlab

Thank you for paying attention to this.
We added a condition under which the option "Ship to the same address" will be available for addresses without countries. Please see this commit for more details.
5 years ago
Thanks a lot.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.