You are here

function theme_uc_cart_checkout_review in Ubercart 8.4

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart.module \theme_uc_cart_checkout_review()
  2. 6.2 uc_cart/uc_cart.pages.inc \theme_uc_cart_checkout_review()
  3. 7.3 uc_cart/uc_cart.pages.inc \theme_uc_cart_checkout_review()

Themes the checkout review order page.

Parameters

array $variables: An associative array containing:

  • form: A render element representing the form, that by default includes the 'Back' and 'Submit order' buttons at the bottom of the review page.
  • panes: An associative array for each checkout pane that has information to add to the review page, keyed by the pane title:

    • <pane title>: The data returned for that pane or an array of returned data.

Return value

string A string of HTML for the page contents.

1 string reference to 'theme_uc_cart_checkout_review'
uc_cart_theme in uc_cart/uc_cart.module
Implements hook_theme().
1 theme call to theme_uc_cart_checkout_review()
CheckoutController::review in uc_cart/src/Controller/CheckoutController.php
Allows a customer to review their order before finally submitting it.

File

uc_cart/uc_cart.theme.inc, line 120
Theme functions for the uc_cart module.

Code

function theme_uc_cart_checkout_review(array $variables) {
  $panes = $variables['panes'];
  $form = $variables['form'];
  $build['instructions'] = [
    '#prefix' => '<p>',
    '#markup' => t("Your order is almost complete. Please review the details below and click 'Submit order' if all the information is correct.  You may use the 'Back' button to make changes to your order if necessary."),
    '#suffix' => '</p>',
  ];
  $rows = [];
  foreach ($panes as $title => $data) {

    // First pane row is the pane title.
    $rows[] = [
      'data' => [
        [
          'data' => $title,
          'colspan' => '2',
        ],
      ],
      'no_striping' => TRUE,
      'class' => [
        'pane-title-row',
      ],
    ];

    // Subsequent pane rows may be subtitles or subtitle-data pairs.
    foreach ($data as $row) {
      if (isset($row['data'])) {
        if (isset($row['border'])) {
          $border = 'row-border-' . $row['border'];
        }
        else {
          $border = '';
        }
        $rows[] = [
          'data' => [
            [
              'data' => $row['title'] . ':',
              'class' => [
                'title-col',
              ],
            ],
            [
              'data' => $row['data'],
              'class' => [
                'data-col',
              ],
            ],
          ],
          'no_striping' => TRUE,
          'class' => [
            $border,
          ],
        ];
      }
      else {

        // Row is the cart review table.
        $rows[] = [
          'data' => [
            [
              'data' => $row,
              'colspan' => '2',
            ],
          ],
        ];
      }
    }
  }
  $rows[] = [
    'data' => [
      [
        'data' => $form,
        'colspan' => '2',
      ],
    ],
    'no_striping' => TRUE,
    'class' => [
      'review-button-row',
    ],
  ];
  $build['review-table'] = [
    '#type' => 'table',
    '#rows' => $rows,
    '#attributes' => [
      'class' => [
        'order-review-table',
      ],
    ],
  ];
  return drupal_render($build);
}