You are here

function commerce_checkout_builder_form_save_submit in Commerce Core 7

Submit handler for the checkout builder form's save button.

1 string reference to 'commerce_checkout_builder_form_save_submit'
commerce_checkout_builder_form in modules/checkout/includes/commerce_checkout.admin.inc
Build the checkout form builder, adding in data for the checkout pages and the appropriate fields to enable tabledrag on the checkout panes.

File

modules/checkout/includes/commerce_checkout.admin.inc, line 128
Administrative callbacks for the Checkout module.

Code

function commerce_checkout_builder_form_save_submit($form, &$form_state) {

  // Loop through each of the checkout panes.
  if (!empty($form_state['values']['panes'])) {
    foreach ($form_state['values']['panes'] as $pane_id => $data) {

      // Load and update the checkout pane array.
      $checkout_pane = commerce_checkout_pane_load($pane_id);
      $checkout_pane['weight'] = $data['weight'];

      // Accommodate the "Disabled" pseudo-page in the form.
      if ($data['page'] == 'disabled') {
        $checkout_pane['enabled'] = FALSE;
        $checkout_pane['page'] = 'disabled';
      }
      else {
        $checkout_pane['enabled'] = TRUE;
        $checkout_pane['page'] = $data['page'];
      }
      commerce_checkout_pane_save($checkout_pane);
    }
  }
  drupal_set_message(t('Checkout pane positions saved.'));
}