This might sound a bit silly, but even though the addressfield is called addressfield, you don't actually have to use it for storing addresses, you can limit it to storing name and/or company name. It happened to fit my use case, since I don't need to store addresses during checkout I thought it was easier to just use it for storing the name which I did need.

Doing this I've found this strange bug, that I'm guessing has something to do with the way customer profile saves the address. I remember that some strange things are going on there.

Anyways the actual bug is that if you don't have the address part enabled in the address field, the addressfield won't actually save the name. What's worse is, that is a name is already stored (temporarily turning the address on, entering data, turn address off and go back), the name will be deleted if the form is submitted again.

So clearly something whacky is going on.

Ryan do you have any hunches, been a long time since I looked at the customer profile and addressfield interaction.

Comments

amateescu’s picture

Project: Commerce Core » Address Field
Version: 7.x-1.2 » 7.x-1.x-dev
Component: Customer » Code

Tested this with an address field attached to a node and I experienced the same behavior. Moving to the Address Field queue.

phuybre’s picture

In addressfield.module, it checks for empty fields

/**
 * Implements hook_field_is_empty().
 */
function addressfield_field_is_empty($item, $field) {
  // Every address field must have at least a country value or it is considered
  // empty, even if it has name information.
  return empty($item['country']);
}

Quick Fix: Change the line to return empty($item['name_line']); and it should work.

Of course, a proper fix would check the configuration of this addressfield instance and react accordingly.

Robin Millette’s picture