thanks for developing this module

I was wondering if we could use the hook_commerce_addressbook_label_alter(&$label, $entity) hook to look-up by a custom field ( customer name ) we added to the Customer Profile instead of by the address ? I'm not quite sure what this hook would look like ?

Comments

bojanz’s picture

Status: Active » Fixed

Sure. $entity is the customer profile.

Sample:

function my_module_commerce_addressbook_label_alter(&$label, $entity) {
  $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $entity);
  $label = $profile_wrapper->my_customer_name_field->value();
}

Note that this hook has changed in 7.x-2.x, it's now hook_commerce_addressbook_labels_alter(&$labels, $profiles).
The principle is the same. You can see its documentation in commerce_addressbook.api.php

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jvb747’s picture

Sorry, but i need to use this hook on checkout and haven't any idea where to put this hook and how it will look like,using $labels and $profiles. Can you help me?