You are here

function commerce_customer_customer_profile_form_submit in Commerce Core 7

Submit callback for commerce_customer_profile_form().

1 string reference to 'commerce_customer_customer_profile_form_submit'
commerce_customer_customer_profile_form in modules/customer/includes/commerce_customer_profile.forms.inc
Form callback: create or edit a customer profile.

File

modules/customer/includes/commerce_customer_profile.forms.inc, line 142
Forms for creating / editing and deleting customer profiles.

Code

function commerce_customer_customer_profile_form_submit($form, &$form_state) {
  global $user;
  $profile =& $form_state['customer_profile'];

  // Save default parameters back into the $profile object.
  $profile->status = $form_state['values']['status'];

  // Set the profile's owner uid based on the supplied name.
  if (!empty($form_state['values']['name']) && ($account = user_load_by_name($form_state['values']['name']))) {
    $profile->uid = $account->uid;
  }
  else {
    $profile->uid = 0;
  }

  // Notify field widgets.
  field_attach_submit('commerce_customer_profile', $profile, $form, $form_state);

  // Save the profile.
  commerce_customer_profile_save($profile);

  // Redirect based on the button clicked.
  drupal_set_message(t('Profile saved.'));
}