You are here

function theme_uc_ups_option_label in Ubercart 8.4

Same name and namespace in other branches
  1. 6.2 shipping/uc_ups/uc_ups.module \theme_uc_ups_option_label()
  2. 7.3 shipping/uc_ups/uc_ups.theme.inc \theme_uc_ups_option_label()

Theming of the customer-facing USPS service name and rate amount line-item.

Parameters

array $variables: Associative array containing information needed to theme a quote. Contains two keys:

  • service: The UPS service name.
  • packages: Package information.

Return value

string Formatted HTML.

1 string reference to 'theme_uc_ups_option_label'
uc_ups_theme in shipping/uc_ups/uc_ups.module
Implements hook_theme().
1 theme call to theme_uc_ups_option_label()
uc_ups_quote in shipping/uc_ups/uc_ups.module
Callback for retrieving a UPS shipping quote.

File

shipping/uc_ups/uc_ups.theme.inc, line 22
Theme functions for the uc_ups module.

Code

function theme_uc_ups_option_label(array $variables) {
  $service = $variables['service'];
  $packages = $variables['packages'];

  // Start with logo as required by the UPS terms of service.
  $build['image'] = [
    '#theme' => 'image',
    '#uri' => drupal_get_path('module', 'uc_ups') . '/images/uc_ups_logo.jpg',
    '#alt' => t('UPS logo'),
    '#attributes' => [
      'class' => [
        'ups-logo',
      ],
    ],
  ];

  // Add the UPS service name.
  $build['label'] = [
    '#plain_text' => t('@service Rate', [
      '@service' => $service,
    ]),
  ];

  // Add package information.
  $build['packages'] = [
    '#plain_text' => ' (' . \Drupal::translation()
      ->formatPlural(count($packages), '1 package', '@count packages') . ')',
  ];
  return drupal_render($build);
}