Address cloning upon placing order

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hello,
first, sorry if my english is buggy.
I have the need of tracking when a user uses the same address when placing different orders, and i noticed that nop clone the address referenced by the user entity upon creating the order:


//clone billing address
billingAddress = (Address)customer.BillingAddress.Clone();


... later on ....

var order = new Order() {
....
BillingAddress = billingAddress,
ShippingAddress = shippingAddress,
....
};


This don't allow me to see (programmatically) if two orders by the same user share the same address (they'll have different IDs).

Why this happens? I mean, even if a user where to delete one of its addresses, it would be sufficient to delete the entry in the mapping table whilst the address for the (eventual) order would remain untouched! It's also waste of space isn't it.

Can i safely override this behaviour?

Thanks in advance for the reply, and huge thanks for this amazing piece of software engineering btw.
12 years ago
I guess this is done for historical reasons. If you ever need to find out what was the exact billing or shipping address for an order, this way you can do it. Only referencing the address is dangerous because the user can still modify it.
12 years ago
Oh yeah he can modify it... well, i guess i'll have to make the service create another address and change the reference upon modify, leaving the old address alone. And maybe add a check on the service that will delete the address when is not referenced anymore (garbage collector anyone?)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.