Currently, the first address line is used it identify the address book entry.
For companies, you often have the same "Address 1" content for different addresses.

It should be great if we had an additional field to allow us to choose the address name used in the dropdown and in the address book.


zhilchenko’s picture

Status: Active » Needs review
2.71 KB

Here is quick patch with such functionality. Apply it, go to admin/commerce/config/addressbook and select field for entry title. Users on checkout will see select box with this field values.

DuaelFr’s picture

Status: Needs review » Needs work

Nice start but :

  1. Billing and Shipping profile types can have different fields so we cannot use just one title field selector for both of them
  2. Creating a field and using it as address book title on existing profiles gives a select box full of untitled entries which cannot be renamed because it just creates new entries

However, good job. Thank you :)

Simon Georges’s picture

Has there been some progress on that? Is someone working on it?

jsacksick’s picture

This is currently possible via code using the hook_commerce_addressbook_labels_alter() (See commerce_addressbook.api.php).

sumaiyajaved’s picture

I am using commerce kickstart, i required a simple address so I had removed the commerce dynamic form and had added custom cck fields. Due to which the address book entry names were coming blank. I tried using the above hook in a custom module but it not change anything.

So i hacked the module :(
went to
$options[$id] = $field_values[0]['thoroughfare'];
and changed it to
$options[$id] = "Address ".$id;

I basically want the title to come from the custom cck fields. Can you help me? (name of the cck field is field_area)

kratos91’s picture

I have the same problem that sumaiyajaved, I`ve deleted the addressfield by and I want to select one of my new fields in order to appear in preovious addresses dropdown , Can you help me please ?

roball’s picture

Title: Allow the user to chosse his address book entry's name » All selectable profile names are blank if there is no "Postal address" field in the Customer profile
Version: 7.x-2.x-dev » 7.x-2.0-rc7
Category: feature » bug
Priority: Normal » Major
Status: Needs work » Active
15.36 KB
31.08 KB

When the Billing information Customer profile type has no longer a Postal address field in it (as the default Commerce module bundle comes with), the administrative list of Customer profiles no longer contains a column "Name" (it only has "Profile ID", "User", "Type", "Status and "Operations") - see attached first screenshot.

As a consequence, on the Billing information checkout pane, the Addresses on File select list only contains empty select options - see attached second screenshot. The corresponding HTML is

<div class="form-item form-type-select form-item-customer-profile-billing-addressbook">
  <label for="edit-customer-profile-billing-addressbook">Addresses on File </label>
 <select id="edit-customer-profile-billing-addressbook" name="customer_profile_billing[addressbook]" class="form-select ajax-processed"><option value="none">-- Choose --</option><option value="4" selected="selected"></option><option value="7"></option></select>
<div class="description">You may select a pre-existing address on file.</div>

Thus, the names displayed in the select options list, should not rely on other modules. Instead, it should generate its own names, maybe including the creation date. I think best would be to configure the generated name based on tokens.

candelas’s picture

same problem

L5’s picture

Same issue here. Any solutions known yet?

roball’s picture

Unfortunately, not yet, since the maintainer did not comment on this bug yet (beside #4, which does however not solve the blank options as by #5).

mvdve’s picture

Category: bug » feature
Priority: Major » Normal

As mentioned in #4 You can use the API of addressbook to alter the dropdown name. Simply add the function to your template.php file and select the field you want to use.

 * Allows modules to alter the list of customer profile labels.
 * During checkout the user selects the "address on file" from a dropdown list
 * of customer profiles. The label used to represent each customer profile
 * is the "thoroughfare" column of the addressfield. By altering the list
 * of labels, a module can use additional data to represent each customer
 * profile. Note that the list should always be keyed by customer profile id.
 * @param $labels
 *   An array of labels, keyed by customer profile id.
 * @param $profiles
 *   An array of customer profile entities.
function hook_commerce_addressbook_labels_alter(&$labels, $profiles) {
  // No example.
roball’s picture

Thank you mvdve for the tipp, but in the meantime I have removed this module from my sites, since I am now successfully using Commerce Single Address instead. It is not causing any problems for me out of the box.

Sanco’s picture

Issue summary: View changes

After using the patch from comment #1 have errors:

Warning: array_filter() expects parameter 2 to be a valid callback, function 'addressfield_field_map_filter' not found or invalid function name в функции addressfield_tokens() (строка 207 в файле .../httpdocs/sites/all/modules/addressfield/
Warning: Invalid argument supplied for foreach() в функции addressfield_tokens() (строка 207 в файле .../httpdocs/sites/all/modules/addressfield/

How to fix?

zhilevan’s picture

I have the same problem in shipping information, customer profile select .

roball’s picture

Category: Feature request » Bug report

Unfortunately, this problem has not been considered to be fixed in the latest release (7.x-2.0-rc8). Any plans?

mglaman’s picture

Category: Bug report » Feature request

roball, it hasn't been considered by the community to provide patches to help fix this. This isn't a bug in my opinion, as you should always have a zip code. A feature to change how the select option label is displayed is a feature.

roball’s picture

@mglaman, did you view the following screenshot?

Billing information checkout pane with empty Addresses on File select options

There are NO select option labels at all. The user just sees a select field with empty options. You want to say that is desired behaviour ???

Also, it has nothing to do with the ZIP code.

mglaman’s picture

@roball, no I do not find that to be desired. However this issue is directed at use-case changes to Customer Profile entities - which is assumed to have an Address Field for Payment modules to properly process. Since this is the de facto setup in Drupal Commerce, this module assumes that as well. So it is a Feature request.

Looking at the screenshot, and based on the comment, I'm assuming there is malformed data and would need more info to investigate, or would more than willingly review a patch which adds support for this.

#1 looks like a proper approach, but it needs to check the field instances on the bundle, but that doesn't help identify sub-values within the field (each address component.)

Yesterday I went through the queue to triage the module, commit fixes, and get things moving again so that items like these can be considered without all the other technical debt amongst it.

radamiel’s picture - here is a module that allows to pick a field. For now it allows only any subfield from address field and textfields

roball’s picture

Thanks radamiel, I am now using Commerce Addressbook together with your Commerce Addressbook Extra module, which solved this issue fine for me.