Commit 8b36c90c authored by rfay's avatar rfay

Issue #1357348 by rfay: checkout page example

parent 3236fb71
name = Checkout Page Example
description = Demonstrates providing an additional checkout page
package = Commerce (contrib)
dependencies[] = commerce_checkout
dependencies[] = checkout_page_example
core = 7.x
<?php
/**
* @file checkout_page_example.module
* Demonstrates the addition of a new page to the checkout system.
*/
/**
* Implements hook_menu().
*
* Simply presents a page that will explain what this module is for.
* hook_menu() has nothing to do with the checkout page functionality.
*/
function checkout_page_example_menu() {
$items['commerce_examples/checkout_page_example'] = array(
'title' => 'Checkout Page Example',
'page callback' => 'checkout_page_example_info_page',
'access callback' => TRUE,
);
return $items;
}
/**
* This function simply returns information about the example to help the
* user understand its purpose.
*/
function checkout_page_example_info_page() {
return array(
'#markup' => t('The page example adds an extra "Page Example" page to the checkout system. It also demonstrates how to alter the pages other modules have provided.'),
);
}
/**
* Implements hook_commerce_checkout_page_info().
*
* This is where we define the name of the page and related information.
*
* @link http://www.drupalcommerce.org/node/224 explains hook_commerce_checkout_page_info @endlink
*/
function checkout_page_example_commerce_checkout_page_info() {
$pages['checkout_page_example'] = array(
'name' => t('Checkout Page Example'),
'title' => t('Checkout Page Example'),
'help' => t('This is some help for the Checkout Page Example. You may not need this page in your own Commerce install :-)'),
// Determines the order of the checkout pages.
'weight' => 10,
// An order status is automatically created for each checkout page. It will
// be named 'Checkout: ' + the name of the page.
// If 'status_cart' is TRUE (default), then the 'cart' property of the order
// status will be set to true, meaning that the commerce_cart module will
// treat this the order as a cart at this point (price recalculations take
// place on reload, and other cart-oriented functions may fire.)
// If 'status_cart' is false, then prices are frozen on this page and
// recalculation does not occur.
'status_cart' => TRUE,
// If 'buttons' is FALSE the next and previous buttons will be omitted.
'buttons' => TRUE,
// The value of the "next" button for this page. Defaults to 'Continue'.
'submit_value' => t('Continue to a real checkout page'),
// The value of the "previous" button for this page. Defaults to 'Back'
'back_value' => t('Go back'),
);
return $pages;
}
/**
* Implements hook_commerce_checkout_page_info_alter().
*
* Here we can change the definitions of pages that have been provided by this
* or other modules. This example will check the weights of other modules and
* then readjust our weight so it always comes first.
*
* We have the ability to reorder and rename pages, change their button names,
* etc.
*
* @param $pages
* All the pages that have been defined.
*/
function checkout_page_example_commerce_checkout_page_info_alter(&$pages) {
$my_weight = PHP_INT_MAX;
// Walk through the weights to find the lowest weight and make ours lower.
foreach ($pages as $index => $page) {
if ($index != 'checkout_page_example' && $page['weight'] < $my_weight) {
$my_weight = $page['weight'] - 1;
}
}
$pages['checkout_page_example']['weight'] = $my_weight;
}
/**
* Implements hook_commerce_checkout_pane_info_alter().
*
* We'll place the example *pane* in our example *page*.
*
* @param $panes
* All the panes that have been defined.
*/
function checkout_page_example_commerce_checkout_pane_info_alter(&$panes) {
$panes['checkout_pane_example']['page'] = 'checkout_page_example';
}
\ No newline at end of file
......@@ -12,7 +12,7 @@
*/
function checkout_pane_example_menu() {
$items['commerce_examples/checkout_pane_example'] = array(
'title' => 'Pane Example',
'title' => 'Checkout Pane Example',
'page callback' => 'checkout_pane_example_info_page',
'access callback' => TRUE,
);
......@@ -39,7 +39,7 @@ function checkout_pane_example_info_page() {
function checkout_pane_example_commerce_checkout_pane_info() {
$panes['checkout_pane_example'] = array(
'title' => t('Pane Example'),
'title' => t('Checkout Pane Example'),
'base' => 'checkout_pane_example_pane',
// The checkout page where this should be displayed by default.
......@@ -159,11 +159,13 @@ function checkout_pane_example_pane_review($form, $form_state, $checkout_pane, $
'#title' => t('Nickname'),
'#markup' => check_plain($order->data['nickname']),
);
$content['another_email'] = array(
'#type' => 'item',
'#title' => t('Another Email address'),
'#markup' => check_plain($order->data['another_email']),
);
if (!empty($order->data['another_email'])) {
$content['another_email'] = array(
'#type' => 'item',
'#title' => t('Another Email address'),
'#markup' => check_plain($order->data['another_email']),
);
}
return drupal_render($content);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment