2

When anonymous user is on checkout page using DRUPAL commerce, I want to autofil email field in Account Information section on checkout page.

I tried using hook_form_alter to give it a default value, but I guess, since this is a multi-step form, so it ignores when goes to REVIEW pane.

if ($form_id == 'commerce_checkout_form_checkout') {
  $buyers_email_retrieve = 'myemail@email.com';
  $form['account']['login']['mail']['#default_value'] = $buyers_email_retrieve;
  $form['account']['login']['mail']['#attributes']['disabled'] = TRUE;
  $form['account']['login']['mail']['#required'] = FALSE;
}

After giving it a default value, it still throws a validation error, so required property is set to FALSE.

| improve this question | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.