Addressbook attaches a field to profiles that allows the user to specify whether that is his "default" address.
This is something that is safe to change even when the profile is already referenced from an order.
So there should be a way to tell commerce_order_commerce_customer_profile_presave() to ignore certain fields when doing the comparison of "did the fields change, should I duplicate the profile?"
I don't know a nice way to do this. Perhaps a key on the entity that gets unset in the end?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1317426.patch | 1.33 KB | bojanz |
| #1 | 1317426.patch | 770 bytes | bojanz |
Comments
Comment #1
bojanz commentedSomething like this perhaps? Doesn't feel very nice, but does the job.
Either an approach such as that one, or advising people for avoiding field api fields for use cases such as this one.
Comment #2
bojanz commentedTweaked it a bit.
Comment #3
czigor commentedDo I understand correctly: the idea is to add the $profile->_ignore_fields somewhere in a hook_form_commerce_checkout_form_checkout_alter()?
So far, I have been doing this by adding an #element_validate callback in hook_form_commerce_checkout_form_checkout_alter() and unsetting the unwanted field there in $form_state['values']. I could do this because I only needed that field for some AJAX form handling.
Comment #4
svendecabooterThis might be somewhat related to the problem i encountered in #1308754: The customer profile duplication code has numerous edge cases that cause profiles to be needlessly duplicated
Comment #5
bojanz commentedDuplicate of #1308754: The customer profile duplication code has numerous edge cases that cause profiles to be needlessly duplicated.