Experimental project

This is a sandbox project, which contains experimental code for developer use only.

This module provides an alternative to the commerce_checkout_router(). It allows you to register a callback (redirect_callback) in hook_commerce_checkout_page_info() which is called with the context of what direction the user is navigating.

This module was developed to provide an easy way to have conditional pages during checkout.

Example

<?php
/**
 * Implements hook_commerce_checkout_page_info().
 */
function HOOK_commerce_checkout_page_info() {
  return array(
    'my_customer_page' => array(
      'name' => 'my_page_name',
      'title' => t('Page title'),
      'weight' => 0,
      'redirect_callback' => 'my_redirect_callback',
    ),
  );
}

/**
 * Redirect callback for "my_customer_page" page.
 *
 * @param object $order
 *   The commerce order object.
 * @param array $checkout_page
 *   The checkout page definition.
 * @param string $direction
 *   The direction you're going. A constant COMMERCE_CHECKOUT_CONTEXT_ROUTER_*
 */
function my_redirect_callback($order, $checkout_page, $direction) {
    if (skip_this_page()) {
      // Redirect to the previous or next page, skipping the page.
      $order = commerce_order_status_update($order, 'checkout_' . $checkout_page[$direction]);
      drupal_goto('checkout/' . $order->order_id . '/' . $checkout_page[$direction]);  
    }
}
?>

Known Issues

If you're redirected to another checkout page without using the checkout router then whatever does the redirect must set the last page status with commerce_checkout_context_router_set_last_status() otherwise this module will have lost it's context.

Supporting organizations: 
Sponsored

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • Created by benjy on , updated