The street address length is too big. It is a 255 varchar column, when it could be only 60. Other stores limit this field, like amazon address field.

This is an issue for us because we have an importer for quickbooks and quickbooks only allows 49 characters even. And some customers abuse this field and make mistakes. For example a lot of users end up duplicating the postal code, estate and other info in the street field.

We are using right now a hook_form_alter to limit this field, but I think it could be safe and even a good usability change to modify this field to only 60 characters like in other stores.

Comments

rszrama’s picture

Title: Street address length » Decrease the maximum length of the street address
Category: Bug report » Feature request
Issue summary: View changes
Status: Active » Closed (won't fix)

As far as I know, there is no standard limitation on street address lengths. While some accounting systems may not support long lengths, I don't know of any external requirement forcing them to make those decisions. Since any limitation would be arbitrary, I'm inclined to leave this as is (since 255 is the default length of the data type in the database) and leave it up to the integration module to do the necessary data transformation. We do this in many other areas, such as in achieving a specific format for numeric amounts when communicating with payment gateways. Using hook_form_alter() on a site by site basis is perfectly legitimate, too.

fonant’s picture

FWIW: The max number of characters the Royal Mail / Metapack labels can accommodate on the first 3 lines of any address is 25 per line.

It also appears that hook_form_alter() doesn't work for Commerce billing and shipping addresses, you have to use hook_field_widget_addressfield_standard_form_alter() instead.

Here's my code to limit the fields within an address:

/**
 * Implements hook_field_widget_addressfield_standard_form_alter().
 */
function MYMODULE_field_widget_addressfield_standard_form_alter(&$element, &$form_state, &$context) {
  $element['street_block']['thoroughfare']['#size'] = 25;
  $element['street_block']['thoroughfare']['#maxlength'] = 25;
  $element['street_block']['premise']['#size'] = 25;
  $element['street_block']['premise']['#maxlength'] = 25;
  $element['locality_block']['locality']['#size'] = 25;
  $element['locality_block']['locality']['#maxlength'] = 25;
  $element['locality_block']['dependent_locality']['#size'] = 25;
  $element['locality_block']['dependent_locality']['#maxlength'] = 25;
  $element['locality_block']['administrative_area']['#size'] = 25;
  $element['locality_block']['administrative_area']['#maxlength'] = 25;
  $element['locality_block']['postal_code']['#size'] = 25;
  $element['locality_block']['postal_code']['#maxlength'] = 25;
}
firfin’s picture

This shows up a lot when searching, so I thought to clarify the above a bit.
This hook does not exist:
hook_field_widget_addressfield_standard_form_alter()
I believer this is meant instead:
hook_field_widget_WIDGET_TYPE_form_alter()