You are here

function theme_uc_product_price in Ubercart 8.4

Same name and namespace in other branches
  1. 5 uc_product/uc_product.module \theme_uc_product_price()
  2. 6.2 uc_product/uc_product.module \theme_uc_product_price()
  3. 7.3 uc_product/uc_product.theme.inc \theme_uc_product_price()

Formats a product's price.

Parameters

array $variables: An associative array containing:

  • element: An associative array render element containing:

    • #value: Price to be formatted.
    • #attributes: (optional) Array of attributes to apply to enclosing DIV.
    • #title: (optional) Title to be used as label.

Return value

string Formatted HTML.

1 string reference to 'theme_uc_product_price'
uc_product_theme in uc_product/uc_product.module
Implements hook_theme().
1 theme call to theme_uc_product_price()
uc_product_view_product in uc_product/uc_product.module
Renders product related content for product-type modules.

File

uc_product/uc_product.theme.inc, line 25
Theme functions for uc_product module.

Code

function theme_uc_product_price(array $variables) {
  $element = $variables['element'];
  $price = $element['#value'];
  $attributes = new Attribute($element['#attributes']);
  $attributes['class'][] = 'product-info';
  $label = isset($element['#title']) ? $element['#title'] : '';
  $output = '<div ' . $attributes . '>';
  if ($label) {
    $output .= '<span class="uc-price-label">' . $label . '</span> ';
  }
  $vars = [
    '#theme' => 'uc_price',
    '#price' => $price,
  ];
  if (!empty($element['#suffixes'])) {
    $vars['#suffixes'] = $element['#suffixes'];
  }
  $output .= drupal_render($vars);
  $output .= drupal_render_children($element);
  $output .= '</div>';
  return $output;
}