function commerce_checkout_pages in Commerce Core 7
Returns an array of checkout pages defined by enabled modules.
Return value
An associative array of checkout page objects keyed by the page_id.
8 calls to commerce_checkout_pages()
- 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.
- commerce_checkout_builder_form_validate in modules/
checkout/ includes/ commerce_checkout.admin.inc - Validation handler for the checkout builder form.
- commerce_checkout_commerce_order_status_info in modules/
checkout/ commerce_checkout.module - Implements hook_commerce_order_status_info().
- commerce_checkout_first_checkout_page in modules/
checkout/ commerce_checkout.module - Returns the page ID of the first checkout page to be used.
- commerce_checkout_page_access in modules/
checkout/ commerce_checkout.module - Checks access to a particular checkout page for a given order.
File
- modules/
checkout/ commerce_checkout.module, line 422 - Enable checkout as a multi-step form with customizable pages and a simple checkout pane API.
Code
function commerce_checkout_pages() {
$checkout_pages =& drupal_static(__FUNCTION__);
// If the checkout pages haven't been defined yet, do so now.
if (empty($checkout_pages)) {
$checkout_pages = module_invoke_all('commerce_checkout_page_info');
drupal_alter('commerce_checkout_page_info', $checkout_pages);
$count = 0;
foreach ($checkout_pages as $page_id => $checkout_page) {
$defaults = array(
'page_id' => $page_id,
'name' => $checkout_page['title'],
'title' => '',
'help' => '',
'status_cart' => TRUE,
'buttons' => TRUE,
'back_value' => t('Go back'),
'submit_value' => t('Continue to next step'),
'prev_page' => NULL,
'next_page' => NULL,
);
$checkout_pages[$page_id] += $defaults;
// Set a weight that preserves the order of 0 weighted pages.
if (empty($checkout_page['weight'])) {
$checkout_pages[$page_id]['weight'] = $count++ / count($checkout_pages);
}
}
uasort($checkout_pages, 'drupal_sort_weight');
// Initialize the previous and next pages.
$previous_page_id = NULL;
foreach ($checkout_pages as &$checkout_page) {
// Look for any checkout panes assigned to this page.
$checkout_panes = commerce_checkout_panes(array(
'page' => $checkout_page['page_id'],
'enabled' => TRUE,
));
// If this is the completion page or at least one pane was found...
if ($checkout_page['page_id'] == 'complete' || !empty($checkout_panes)) {
// If a page has been stored as the previous page...
if ($previous_page_id) {
// Set the current page's previous page and the previous page's next.
$checkout_page['prev_page'] = $previous_page_id;
$checkout_pages[$previous_page_id]['next_page'] = $checkout_page['page_id'];
}
// Set the current page as the previous page for the next iteration.
$previous_page_id = $checkout_page['page_id'];
}
}
}
return $checkout_pages;
}