I was wondering how I can get a list of the available checkout fields of Drupal Commerce like: Billing information:

  • first name
  • last name
  • [custom field]
  • country ...etc.

So i'm only interested in listing the available field names, not the actual values. With code in my custom module.

Does anyone have a suggestion how to do that? Thanks!

1 Answer 1


If I understood you correctly, you want to get a list of the form fields that a user is presented. The isn't really a clean way of doing that, since Drupal forms can be complex. The best solution however would be to generate the form and traverse it. To generate the form, you could do something like this:

$form_state = array();
$fields = array();
$profile = commerce_customer_profile_new('billing');
field_attach_form('commerce_customer_profile', $profile, $fields, $form_state);
// $fields is now the customer profile form.
  • Yes, thank you! In $fields['commerce_customer_address']['und'][0]['#columns'] was the data that I was looking for.
    – Floris248
    Feb 15, 2012 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.