You are here

commerce_registration.theme.inc in Commerce Registration 7.3

Same filename and directory in other branches
  1. 7.2 includes/commerce_registration.theme.inc

Commerce Registration theme functions.

File

includes/commerce_registration.theme.inc
View source
<?php

/**
 * @file
 * Commerce Registration theme functions.
 */

/**
 * Theme callback for the checkout review pane.
 */
function theme_commerce_registration_review_pane($variables) {
  $registrations = $variables['registrations'];
  $settings = registration_entity_settings('commerce_product', $variables['product']->product_id
    ->value());
  $limit = $settings['settings']['limit_registrations'];
  $args = array(
    '!title' => $variables['product']->title
      ->value(),
    '%count' => format_plural(count($registrations), '1 registration', '@count registrations'),
  );
  $output = '<h3 class="commerce-product-title product-title">' . t('!title (%count)', $args) . '</h3><hr>';
  switch ($limit) {
    case 'registrations':

      // Multiple registrations per single quantity of product.
      $rows = array();
      foreach ($registrations as $key => $quantity) {
        $j = 1;
        $label = $key + 1;
        $qargs = array(
          '!title' => $args['!title'],
          '!count' => $label,
        );
        $rows[] = array(
          array(
            'data' => t('Registrations for !title - Quantity #!count', $qargs),
            'colspan' => 2,
            'header' => TRUE,
          ),
        );
        foreach ($quantity as $registration) {
          $row = array(
            array(
              'data' => t('Registrant #!count', array(
                '!count' => $j++,
              )),
            ),
            array(
              'data' => theme('commerce_registration_review_registration', array(
                'registration' => $registration,
              )),
            ),
          );
          $rows[] = $row;
        }
      }
      $output = theme('table', array(
        'rows' => $rows,
      ));
      break;
    case 'slots':

      // Single registration per single quantity of product, taking up multiple slots.
      $i = 1;
      $header = array(
        array(
          'data' => t('Registrations for !product', array(
            '!product' => $args['!title'],
          )),
          'colspan' => 2,
        ),
      );
      $rows = array();
      foreach ($registrations as $registration) {
        $row = array(
          array(
            'data' => t('Registrant #!count', array(
              '!count' => $i++,
            )),
          ),
          array(
            'data' => theme('commerce_registration_review_registration', array(
              'registration' => $registration,
            )),
          ),
        );
        $rows[] = $row;
      }
      $output = theme('table', array(
        'header' => $header,
        'rows' => $rows,
      ));
      break;
  }
  return $output;
}

/**
 * Theme callback to theme a single registration for checkout review.
 */
function theme_commerce_registration_review_registration($variables) {
  $reg_wrapper = entity_metadata_wrapper('registration', $variables['registration']);
  $email = $reg_wrapper->mail
    ->value();
  $output = "<p><span class='registration-email'><strong>" . t("Email") . ":</strong> " . check_plain($email) . "</span></p>";
  $output .= "<p><span class='registration-slots'><strong>" . t("Slots") . ":</strong> " . check_plain($reg_wrapper->count
    ->value()) . "</span></p>";
  $field_view = field_attach_view('registration', $variables['registration'], 'review_pane');
  $output .= drupal_render($field_view);
  return $output;
}

Functions

Namesort descending Description
theme_commerce_registration_review_pane Theme callback for the checkout review pane.
theme_commerce_registration_review_registration Theme callback to theme a single registration for checkout review.