Hi guys,
During the upgrade of our best selling One Page Checkout plugin we noticed that nopCommerce 4.30 handles customer billing and shipping addresses quite differently than nopCommerce 4.20.
In previous versions the logic of obtaining the customer Billing or Shipping addresses relied only on the BillingAddressId/ShippingAddressId properties of the customer and their respective navigation properties.
But in nopCommerce 4.30 there are new methods in the customer service GetCustomerBillingAddress and GetCustomerShippingAddress that get the addresses by checking if they exists in the customer address mappings rather than getting them simply by their IDs as it used to be in previous versions of nopCommerce.
This is quite different than what it used to be in nopCommerce 4.20 where we have never been expected to force the addresses to be part of the address book of the customer.
Actually we used this functionality in our One Page Checkout plugin to create "temp" addresses during the checkout and add them to the address book only when the order is confirmed.
Now we are "forced" to always keep these "temp" addresses in the address book which of course we would like to prevent as we want to keep the address book as clean as possible.
Now if we set a billing address to the customer and this billing address is not part of the address book for that customer we end up with an exception when we call GetCustomerBillingAddress, instead of just returning the address by its ID as it used to be in previous versions of nopCommerce.
What is the reason for this change? Why should the address always be part of the address book? What is the reason for this limitation?
Actually in the regular checkout where you always specify the address first before calculating any payment or shipping options etc. it is OK to put the address in the address book after the address step as you can't change it any longer but in a plugin like our One Page Checkout (and I guess other similar plugins by other vendors) you can make changes to the addresses all the time until you finally Confirm the order. At the same time we don't want to change any of the existing addresses already saved in the address book. That is why we need the option to have "temp checkout" addresses until the checkout is not finished yet. Only after the checkout is finished we decide if this is a new address or it matches any of the existing ones and then we add it to the address book if it is a new one.
I hope this makes sense and it would be great if you can leave the old behavior and simply get the addresses by their IDs rather than trying to get them from the customer's address book.
Thank you for looking at this!
Boyko