Closed (duplicate)
Project:
Commerce Addressbook
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Dec 2011 at 11:21 UTC
Updated:
13 Mar 2012 at 12:59 UTC
I have a customer profile with two addressfields (commerce_customer_address and field_shipping_address). (I also have a textfield for phonenumber but I think it's irrelevant.)
I'm using commerce_addressbook to load existing customer profiles.
However, in DC core's commerce_order_commerce_customer_profile_presave() only commerce_customer_address is handled as an addressfield, field_shipping_address is not. Therefore, if I select an existing customer profile, it is handled as a new one and saved again. See line:
if ($field_name == 'commerce_customer_address') {
This only happens if there is an existing order for that customer profile already, I'm not sure why.
Comments
Comment #1
rszrama commentedI'm not sure there's a bug here; it sounds like you just may not understand why or how duplication happens. From what I can tell in your post, it sounds like duplication should be happening. Is there a reason you think it shouldn't? It's supposed to happen any time a profile is edited and saved after being referenced by an order.
Comment #2
czigor commentedI think it should not save because my profile is loaded but it's not edited.
commerce_addressbook provides a dropdown to the billing information form to select existing profiles. I choose one and without editing the fields I click 'Continue to next step'. That's when a new profile with the exact same fields gets created.
The problem is that addressfield has uninitialized variables when loaded from the database while the data obtained from form_state does not have these variables at all. This is known, that's why there's a separate if-branch for commerce_customer_address. However, if you have another addressfield it is always identified as 'changed'.
commerce_order_commerce_customer_profile_presave() has some useful comments that explain the same thing I'm trying to explain here.
Comment #3
rszrama commentedOk, sorry, it's been a while since I wrote that code. : P
What's interesting to me is that Commerce Addressbook is loading and saving profiles at all. Maybe the issue is that it's happening before the order gets updated with the profile reference.
Comment #4
amateescu commentedThere's been a lot of work on a 7.x-2.x branch for Commerce Adressbook in this sandbox: http://drupal.org/sandbox/eclipsegc/1409158. Can you please give it a try and see if it fixes your problem?
Comment #5
itamair commentedmmmhhh ... I checked the 7.x-2.x branch for Commerce Adressbook in that sandbox (http://drupal.org/sandbox/eclipsegc/1409158).,
updating from this module, but still same addresses (with custom billing profile fields) get duplicated every time, though exactly identical ....
Comment #6
bojanz commented#1308754: The customer profile duplication code has numerous edge cases that cause profiles to be needlessly duplicated should fix this.
Comment #6.0
bojanz commentedProvide further explanation