Skip navigation
Help

theme_uc_product_price

6 uc_product.module theme_uc_product_price($price, $context, $options = array())
7 uc_product.theme.inc theme_uc_product_price($variables)

Formats a product's price.

Parameters

$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.

Related topics

File

ubercart/uc_product/uc_product.theme.inc, line 65
Theme functions for uc_product module.

Code

function theme_uc_product_price($variables) {
  $element = $variables['element'];
  $price = $element['#value'];
  $attributes = isset($element['#attributes']) ? $element['#attributes'] : array();
  $label = isset($element['#title']) ? $element['#title'] : '';

  if (isset($attributes['class'])) {
    array_unshift($attributes['class'], 'product-info');
  }
  else {
    $attributes['class'] = array('product-info');
  }

  $output = '<div ' . drupal_attributes($attributes) . '>';
  if ($label) {
    $output .= '<span class="uc-price-label">' . $label . '</span> ';
  }
  $vars = array('price' => $price);
  if (!empty($element['#suffixes'])) {
    $vars['suffixes'] = $element['#suffixes'];
  }
  $output .= theme('uc_price', $vars);
  $output .= drupal_render_children($element);
  $output .= '</div>';

  return $output;
}