Customer attributes and addresses

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 年 前
I need some explanation regarding addresses of customers:  I had a look in the source code of register endpoint. When a new customer registers, all the address information is written first to the customer attributes (NopCustomerDefaults.StreetAddressAttribute and so on) and in addition an address record is created. What are address attributes used for - why do we need to store it twice?
3 年 前
The addresses billing and shipping are created, stored and referenced in the order at a point in time.
For instance one order may be requested to be delivered to location X and other order to be delivered to location Y.
One order has one billing name contact address and the next order could have another name contact and address details.

Of course a new address record only needs to be created if the details change for each new order otherwise the existing address are referenced and a new address record is not created.

The original address attributes entered are used as a suggestion for the order shipping and billing address and the shipping address can be made the same as the billing address and not selected, all depending on the options selected for the checkout.
3 年 前
Yidna wrote:
...a new address record only needs to be created if the details change for each new order otherwise the existing address are referenced and a new address record is not created...

That's not quite right.  A copy of the addresses is always made when the order is placed (as per OrderProcessingService.cs)
protected virtual async Task<PlaceOrderContainer> ...
...
    details.BillingAddress = _addressService.CloneAddress(billingAddress);

The reason is that the customer could later Edit his addresses in his Account.  So, the Order preserves the address info at the time the order was placed.

Think of the customer's address attributes as "demographic", like his name. (Yet, he store setup can make the address entry as optional.)   Then, as a convenience ( as Yidna mentions: "suggestion") to the customer at the time of checkout, the customer can choose one of his saved addresses.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.