You are here

function theme_uc_product_attributes in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 uc_attribute/uc_attribute.theme.inc \theme_uc_product_attributes()
  2. 6.2 uc_attribute/uc_attribute.admin.inc \theme_uc_product_attributes()

Returns a themed set of attribute options for use in order displays.

Parameters

$variables: An associative array containing:

  • attributes: An associative array containing the set of attributes, with each element keyed by attribute ID:

    • <aid>: An associative array containing:

      • #attribute_name: Attribute name.
      • #options: Array of option names.

Return value

Themed set of attribute options.

2 theme calls to theme_uc_product_attributes()
hook_uc_product_description in uc_product/uc_product.api.php
Returns a structured array representing the given product's description.
uc_attribute_uc_product_description in uc_attribute/uc_attribute.module
Implements hook_uc_product_description().

File

uc_attribute/uc_attribute.admin.inc, line 1087
Attribute administration menu items.

Code

function theme_uc_product_attributes($variables) {
  $attributes = $variables['attributes'];
  $option_rows = array();
  foreach (element_children($attributes) as $key) {
    $optionstr = '';
    foreach ((array) $attributes[$key]['#options'] as $option) {

      // We only need to allow translation from the second option onward
      if (empty($optionstr)) {
        $optionstr .= $option;
      }
      else {
        $optionstr .= t(', !option', array(
          '!option' => $option,
        ));
      }
    }
    if ($optionstr != '') {
      $option_rows[$key] = t('@attribute: @option', array(
        '@attribute' => $attributes[$key]['#attribute_name'],
        '@option' => $optionstr,
      ));
    }
  }
  if (!empty($option_rows)) {
    return theme('item_list', array(
      'items' => array_values($option_rows),
      'attributes' => array(
        'class' => array(
          'product-description',
        ),
      ),
    ));
  }
  return '';
}