You are here

function commerce_checkout_line_item_views_form_submit in Commerce Core 7

Submit handler used to redirect to the checkout page.

1 string reference to 'commerce_checkout_line_item_views_form_submit'
commerce_checkout_form_alter in modules/checkout/commerce_checkout.module
Implements hook_form_alter().

File

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

Code

function commerce_checkout_line_item_views_form_submit($form, &$form_state) {
  $order = commerce_order_load($form_state['order']->order_id);

  // Set the order status to the first checkout page's status.
  $order_state = commerce_order_state_load('checkout');
  $form_state['order'] = commerce_order_status_update($order, $order_state['default_status'], TRUE);

  // Skip saving in the status update and manually save here to force a save
  // even when the status doesn't actually change.
  if (variable_get('commerce_order_auto_revision', TRUE)) {
    $form_state['order']->revision = TRUE;
    $form_state['order']->log = t('Customer proceeded to checkout using a submit button.');
  }
  commerce_order_save($form_state['order']);

  // Redirect to the checkout page if specified.
  if ($form_state['triggering_element']['#value'] === $form['actions']['checkout']['#value']) {
    $form_state['redirect'] = 'checkout/' . $order->order_id;
  }
}