You are here

function hook_commerce_checkout_page_info in Commerce Core 7

Defines checkout pages available for use in the checkout process.

The checkout form is not a true multi-step form in the Drupal sense, but it does use a series of connected menu items and the same form builder function to present the contents of each checkout page. Furthermore, as the customer progresses through checkout, their order’s status will be updated to reflect their current page in checkout.

The Checkout module defines several checkout pages in its own implementation of this hook, commerce_checkout_commerce_checkout_page_info():

  • Checkout: the first page where the customer will enter their basic order information
  • Review: a page where they can verify that the details of their order are correct (and the default location of the payment checkout pane if the Payment module is enabled)
  • Complete - the final step in checkout displaying pertinent order details and links

The Payment module adds an additional page:

  • Payment: a page that only appears when the customer selected an offsite payment method; the related checkout pane handles building the form and automatically submitting it to send the customer to the payment provider

The checkout page array contains properties that define how the page should interact with the shopping cart and order status systems. It also contains properties that define the appearance and use of buttons on the page.

The checkout page array structure is as follows:

  • page_id: machine-name identifying the page using lowercase alphanumeric characters, -, and _
  • title: the Drupal page title used for this checkout page
  • name: the translatable name of the page, used in administrative displays and the page’s corresponding order status; if not specified, defaults to the title
  • help: the translatable help text displayed in a .checkout-help div at the top of the checkout page (defined as part of the form array, not displayed via hook_help())
  • weight: integer weight of the page used for determining the page order; populated automatically if not specified
  • status_cart: boolean indicating whether or not this page’s corresponding order status should be considered a shopping cart order status (this is necessary because the shopping cart module relies on order status to identify the user’s current shopping cart); defaults to TRUE
  • buttons - boolean indicating whether or not the checkout page should have buttons for continuing and going back in the checkout process; defaults to TRUE
  • back_value: the translatable value of the submit button used for going back to a previous page in the checkout process, which is different from the cancel button used to exit the checkout process from the first checkout page; defaults to ‘Go back’
  • submit_value: the translatable value of the submit button used for going forward in the checkout process; defaults to ‘Continue’
  • prev_page: the page_id of the previous page in the checkout process; should not be set by the hook but will be populated automatically when the page is loaded
  • next_page: the page_id of the next page in the checkout process; should not be set by the hook but will be populated automatically when the page is loaded

Note: At this point there is no way to add checkout pages via the UI, so sites wishing to add extra steps to the checkout process will need to define custom pages.

Return value

An array of checkout page arrays keyed by page_id.

2 functions implement hook_commerce_checkout_page_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

commerce_checkout_commerce_checkout_page_info in modules/checkout/commerce_checkout.module
Implements hook_commerce_checkout_page_info().
commerce_payment_commerce_checkout_page_info in modules/payment/commerce_payment.module
Implements hook_commerce_checkout_page_info().
1 invocation of hook_commerce_checkout_page_info()
commerce_checkout_pages in modules/checkout/commerce_checkout.module
Returns an array of checkout pages defined by enabled modules.

File

modules/checkout/commerce_checkout.api.php, line 150
Hooks provided by the Checkout module.

Code

function hook_commerce_checkout_page_info() {
  $checkout_pages = array();
  $checkout_pages['complete'] = array(
    'name' => t('Complete'),
    'title' => t('Checkout complete'),
    'weight' => 50,
    'status_cart' => FALSE,
    'buttons' => FALSE,
  );
  return $checkout_pages;
}