You are here

function commerce_checkout_form_alter in Commerce Core 7

Same name and namespace in other branches
  1. 8.2 modules/checkout/commerce_checkout.module \commerce_checkout_form_alter()

Implements hook_form_alter().

File

modules/checkout/commerce_checkout.module, line 248
Enable checkout as a multi-step form with customizable pages and a simple checkout pane API.

Code

function commerce_checkout_form_alter(&$form, &$form_state, $form_id) {
  if (strpos($form_id, 'views_form_commerce_cart_form_') === 0) {

    // Only add the Checkout button if the cart form View shows line items.
    $view = reset($form_state['build_info']['args']);
    if (!empty($view->result)) {
      $form['actions']['checkout'] = array(
        '#type' => 'submit',
        '#value' => t('Checkout'),
        '#weight' => 5,
        '#access' => user_access('access checkout'),
        '#submit' => array_merge($form['#submit'], array(
          'commerce_checkout_line_item_views_form_submit',
        )),
      );
    }
  }
}