Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home1/tylerfra/public_html/includes/common.inc).

Drupal Commerce Address Field - How to make the company required?

Category: 

It's possible to make the Organisation name (aka Company) field on an Address required during the Drupal Commerce checkout process. With a custom module, you can do this:

/**
 * Implements hook_form_alter().
 */
function my_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'commerce_checkout_form_checkout') {
    $form['customer_profile_billing']['commerce_customer_address']['und'][0]['organisation_block']['organisation_name']['#required'] = TRUE;
  }
}

Comments

Hi, thanks for the helpful post. But how can I allow image/doc upload in commerce field. 

tyler's picture

Commerce Orders are Drupal Entities, so you can add fields to them just like a content type. Go to:

Store -> Configuration -> Order settings -> Manage fields