Hi,
I've enabled 'Address Populate' checkbox, and the user already has customer profile .
but when new checkout happen, there is no populate data on the Billing information Pane, (user have to Input the address information again)
Is there something I'm missing ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

iMiksu’s picture

In address populate we don't use customer profiles. The address gets cloned from user's postal address fields, not customer profiles.

Please follow the next steps to get that working:

  1. Create new field for user in admin/config/people/accounts/fields, name it as Address, field: Postal address, widget: Dynamic address form
  2. Save and configure
  3. Enable 'Address Populate'
  4. Go to checkout pane configuration of 'Billing address' (usually), admin/commerce/config/checkout/form/pane/customer_profile_billing
  5. Choose from Select account's address field to be Address

Does this help your issue?

iMiksu’s picture

Category: bug » feature
iMiksu’s picture

Category: feature » support
rei’s picture

ok, the populate works, but still the New customer profile being created again after new order happened. and user still have to fill in name on the billing pane on checkout page. so what does the purpose of the populate feature if user have to fill in name again and customer profile has to be created again automatically?

iMiksu’s picture

Status: Active » Postponed (maintainer needs more info)

Do you mean the customer profile gets created on each completed checkout process? That's how it should work.

rei’s picture

hmm, If I checkout 20 times with the same name and the same address, then there will be created 20 customer profile with the same identical data owned by the same user. Is this efficient ? . I think the purpose of Populate feature is to not creating the same data over and over again IF there is already available data. the creation of new customer profile should be done 1 time only for the unique address and name.

Anonymous’s picture

I'm testing the population with the alpha1 and it worked for me after I added an addressfield with the field name "address".

I can understand that saving an new customer profile with every new order is not the best way, but it works and future version of commerce will deal with that as well. So far I don't have seen a commerce shop where a client made so many orders that it became a real problem.

iMiksu’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

The original goal of address populate, is just to populate the fields for you according to the information you have in your account.

If we want to change the module to to handle customer profiles, it's totally different topic. Right? That kind of functionality sounds like Commerce Addressbook, so I probably would use that instead.

As @mikewink said, the problem isn't major if we have multiple customer profiles having same information.

118218’s picture

Hi,

For me it really does not work ..

I checked the configuration many times and everything is ok

Apparently it is this part of the code that causes problems:

foreach ($user_fields->{$user_address_field}[$langcode][0] as $key => $value) {
            if (isset($form['commerce_customer_address'][$langcode][0]['#address'][$key])) {
              $form['commerce_customer_address'][$langcode][0]['#address'][$key] = $value;
            }
}

The variable $value contains my fields content as expected (Country, Postal Code, City, Address 1, Address 2 configured in user account). But this condition isn't satisfied:

if (isset($form['commerce_customer_address'][$langcode][0]['#address'][$key])

So the form fields in "Billing Information" are not fulfilled. You know what's the problem?

118218’s picture

Status: Closed (works as designed) » Active
zach.bimson’s picture

Title: Address Populate Not Working » Address Populate Not Working - auto fields based on country

The problem im experiencing is related to this. Auto population is working as it should its the auto FIELDS based on country that aren't working.

For example:

All standard billing fields are populated but there is no post code box is shown.
If I then change the country from United kingdom to something else and back again the fields update and all information is displayed correctly.

Thanks,
Zach

mrfelton’s picture

Status: Active » Needs review
FileSize
3.39 KB

Yes, the issue is as stated in #11. You can't just set the default values, you actually need to regenerate the widget so that it starts off with the correct set of fields for the default country.

mrfelton’s picture

Category: support » bug
iMiksu’s picture

Has anyone tested the patch?

Is it possible to provide clear steps how to reproduce this? Is it AJAX related? Or having different set of address subfields in user than in the form?

j0rd’s picture

Patch #12 completely pulls in a wrong field. The field it's supposed to pull in my address is in Canada, and this patch pulls in an address from Alaska in the USA.

There's definitely a bug in this code I would believe.

Here's the issue I'm personally having with this module:

Enable Canada in your address field. Set your users location to Canada -> British Columbia -> Vancouver. Make sure your default country in Address field is United State (it is by default).

Then head to checkout and you'll notice "Country" and "City" are pre-filled correctly, but "State / Province" is not.

pramodganore’s picture

diff --git a/sites/all/modules/commerce_extra/modules/address_populate/commerce_extra_address_populate.module b/sites/all/modules/commerce_extra/modules/address_populate/commerce_extra_address_populate.module
index 98af41e..5d99687 100644
--- a/sites/all/modules/commerce_extra/modules/address_populate/commerce_extra_address_populate.module
+++ b/sites/all/modules/commerce_extra/modules/address_populate/commerce_extra_address_populate.module
@@ -72,6 +72,11 @@ function commerce_extra_address_populate_field_attach_form($entity_type, $entity
$langcode = is_null($langcode) ? LANGUAGE_NONE : $langcode;
foreach ($user_fields->{$user_address_field}[$langcode][0] as $key => $value) {
if (isset($form['commerce_customer_address'][$langcode][0]['#address'][$key])) {
+ if($key=='country' && $value != $form['commerce_customer_address'][$langcode][0]['#address'][$key]){
+ $address['country'] = $value;
+ $administrative_area = custom_misc_get_format_option($address);
+ $form['commerce_customer_address'][$langcode][0]['locality_block']['administrative_area'] = $administrative_area;
+ }
$form['commerce_customer_address'][$langcode][0]['#address'][$key] = $value;
}
}

rob3000’s picture

Issue summary: View changes
FileSize
13.53 KB

Just tried to reroll patch in comment #12 and it still doesn't work as @j0rd mentioned in comment #15

Replicated by doing the following:

Go to user account and enter default address as the following:

Country: Canada
City: Vancouver
Province: British Columbia
Postal Code: 12345

Add something to cart go to billing profile and State is not pre-filled.
However....
This does work when selecting Australia, the state field is pre-filled and works as expected.

I will investigate further to narrow down which countries it is effecting.

rob3000’s picture

Status: Needs review » Needs work
rob3000’s picture

I've managed to track it down to addressfield setting the default country before the commerce_extra_address_populate_field_attach_form function kicks in and sets the default country.

Ideally it would be great if addressfield module had a drupal_alter just before the default address is set so we can add our default. I'm just about to add the issue and patch to addressfield module but wondering if anyone else had any ideas??

Maico de Jong’s picture

I don't have the time to create a patch now(added to the todo list:) but i've managed to fix #19 by using the new hook_addressfield_default_values_alter()

thomas.wardin’s picture

@MDJ Webdiensten: Could you write a dummy-howto please?

gatiba’s picture

Hi @thomas,
i resolved my commerce extra populate problems overriding hook_addressfield_default_values_alter() like @MDJ pointed out.
This is my personal working solution, i force the default country on commerce pane so all the fields (first of all the "province" one) are correctly set:

function mymodule_addressfield_default_values_alter(&$default_values, $context) {
  global $user;
  $user_data = user_load($user->uid);
  if($context['field']['field_name'] == 'commerce_customer_address') {
    if( !empty($user_data->field_shipping_address['und'][0]['country']) ) {
      $default_values['country'] = $user_data->field_shipping_address['und'][0]['country'];
    }
  }
}

Tell me if you need more help!