You are here

function commerce_checkout_review_pane_checkout_form in Commerce Core 7

Checkout pane callback: returns a pane allowing the customer to review the details of the order.

File

modules/checkout/includes/commerce_checkout.checkout_pane.inc, line 13
Checkout pane callback functions for the checkout module.

Code

function commerce_checkout_review_pane_checkout_form($form, &$form_state, $checkout_pane, $order) {
  $pane_form = array();

  // Otherwise add any enabled checkout panes that are visible on review.
  $pane_form['review'] = array(
    '#theme' => 'commerce_checkout_review',
    '#data' => array(),
  );

  // Loop through all the pages before the review page...
  foreach (commerce_checkout_pages() as $page_id => $checkout_page) {

    // Exit the loop once the review page is reached.
    if ($page_id == 'review') {
      break;
    }

    // Loop through all the panes on the current page specifying review...
    foreach (commerce_checkout_panes(array(
      'page' => $page_id,
      'enabled' => TRUE,
      'review' => TRUE,
    )) as $pane_id => $checkout_pane_local) {

      // If the pane has a valid review callback...
      if ($callback = commerce_checkout_pane_callback($checkout_pane_local, 'review')) {

        // Get the review data for this pane.
        $pane_data = $callback($form, $form_state, $checkout_pane_local, $order);

        // Only display the pane if there is data in the pane.
        if (!empty($pane_data)) {

          // Add a row for it in the review data.
          $pane_form['review']['#data'][$pane_id] = array(
            'title' => $checkout_pane_local['title'],
            'data' => $pane_data,
          );
        }
      }
    }
  }
  return $pane_form;
}