function commerce_checkout_form_cancel_submit in Commerce Core 7
Special submit handler for the cancel button to avoid processing orders.
2 string references to 'commerce_checkout_form_cancel_submit'
- commerce_cart_form_alter in modules/
cart/ commerce_cart.module - Implements hook_form_alter().
- commerce_checkout_form in modules/
checkout/ includes/ commerce_checkout.pages.inc - Builds the checkout form for the given order on the specified checkout page.
File
- modules/
checkout/ includes/ commerce_checkout.pages.inc, line 435 - The page and form callbacks for use in the checkout form.
Code
function commerce_checkout_form_cancel_submit($form, &$form_state) {
$order = commerce_order_load($form_state['order']->order_id);
// Set the order status back 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 manually canceled the checkout process.');
}
commerce_order_save($form_state['order']);
drupal_set_message(t('Checkout of your current order has been canceled and may be resumed when you are ready.'));
$form_state['redirect'] = $form_state['cancel_redirect'];
}