1

I am using Drupal 7 with commerce module. In the commerce shipping pane I have created a new email filed through admin -> store -> Customer profiles -> Shipping Information and it is displaying in the shipping section that’s all fine.

Now what I have to do here is use this email while creating the account for anonymous users instead of using email from the account pane and also I need to hide the email filed in account pane. Can anyone guide me how to implement this? Thanks in advance.

Ratheesh

1
  • Anonymous users will be asked to enter an email address anyway when checking out, what is wrong with using the default email field? You seem to be making things harder for yourself.
    – Collins
    Commented Jan 12, 2015 at 20:15

1 Answer 1

0

I have resolved the issue like adding a submit handler function when click on continue button click. Code is provided below

your-module_form_alter(&$form, $form_state, $form_id) {
   global $user;
   if(!$user->name){
      $form['account']['login']['mail']['#required'] = 0;
      $form['account']['login']['mail']['#prefix'] = '<div style="display: none;">';
      $form['account']['login']['mail']['#suffix'] = '</div>';
      array_unshift($form['buttons']['continue']['#validate'], 'your-module_submit_handler');
    }
}

your-module_submit_handler(&$form, &$form_state){
    $form_state['values']['account']['login']['mail'] = $form['customer_profile_shipping']['field_email']['und'][0]['value']['#value'];
}

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.