Why does NopCommerce add the shipping address to the database in OrderProcessingService.SaveOrderDetails() ?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 年 前
Hi guys,

Really specific question here, why would NopCommerce add the shipping address in the SaveOrderDetails method?

For version 4.3, this would be line 825:

            if (details.ShippingAddress != null)
            {
                _addressService.InsertAddress(details.ShippingAddress);
                order.ShippingAddressId = details.ShippingAddress.Id;
            }

Wouldn't this just keep reduplicating the same address in the database over and over?

Wouldn't it be better to just use the existing address?

Just a bit confused here because this feature is causing a referential issue with our API which is based on NopCommerce. Our API consumers are sending in the address they want for the order and by the time the order is created a new address is associated to the order.

Obviously the new address will have a different Id and therefore, our API consumers are just left confused why this is the case.
3 年 前
Because you want to keep a record of the address at the time of the purchase.

The customer may change their address at some point after the order is placed and then you don’t have a correct record stored of where the delivery was actually sent.
The customer may also want their delivery to go somewhere else - not their home address.

Of course there is the case when they change their address after an order is made and before it is delivered -  then you may want to ask the customer the question "You have a delivery outstanding do you want to update the shipping address for this delivery address. :)
3 年 前
Thanks mate.

Started to think about this as well and it does make sense.

My team will have to work around this I guess with our API. Probably not return Ids for addresses would be a good thing especially if NopCommerce works in this way.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.