これがuser_register_formコマースチェックアウトペインを作成する方法です。
/**
* Implements hook_commerce_checkout_pane_info().
*/
function edw_commerce_dc_commerce_checkout_pane_info() {
$panes['register'] = [
'title' => t('Create an account'),
'base' => 'edw_commerce_dc_register_pane',
'name' => t('Authentication'),
'file' => 'edw_commerce_dc.pane.inc',
'page' => 'checkout',
'weight' => -5,
];
return $panes;
}
/*
* Alter checkout form register pane
*/
function edw_commerce_dc_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {
unset($form['register']['actions']);
if(isset($form['register'])){
$form_id = 'user_register_form';
$hooks = array('form');
$hooks[] = 'form_' . $form_id;
drupal_alter($hooks, $form['register'], $form_state, $form_id);
}
}
/*
* Add user_register_form to register pane
*/
function edw_commerce_dc_register_pane_checkout_form($form, &$form_state, $checkout_pane, $order) {
if (user_is_anonymous()) {
$pane_form = drupal_retrieve_form('user_register_form', $form_state);
$pane_form['#tree'] = FALSE;
return $pane_form;
}
}
/**
* checkout form submission callback.
*/
function edw_commerce_dc_register_pane_checkout_form_submit($form, &$form_state, $checkout_pane, $order) {
if (isset($form['register'])) {
foreach ($form["register"]["#submit"] as $callback) {
$callback($form['register'], $form_state);
}
}
}
/**
* checkout form submission callback.
*/
function edw_commerce_dc_register_pane_checkout_form_validate($form, &$form_state, $checkout_pane, $order) {
if (isset($form['register'])) {
foreach ($form["register"]["#validate"] as $callback) {
$callback($form['register'], $form_state);
}
if (!form_get_errors()) {
return TRUE;
}
}
}