You are here

function commerce_cart_attribute_widget_title in Commerce Core 7

Returns the title of an attribute widget for the Add to Cart form.

Parameters

$instance: The attribute field instance info array.

Return value

A sanitized string to use as the attribute widget title.

1 call to commerce_cart_attribute_widget_title()
commerce_cart_add_to_cart_form in modules/cart/commerce_cart.module
Builds an Add to Cart form for a set of products.

File

modules/cart/commerce_cart.module, line 1668
Implements the shopping cart system and add to cart features.

Code

function commerce_cart_attribute_widget_title($instance) {

  // Translate the entire field instance and find the default title.
  $translated_instance = commerce_i18n_object('field_instance', $instance);
  $title = $translated_instance['label'];

  // Use the customized attribute widget title if it exists.
  $commerce_cart_settings = commerce_cart_field_instance_attribute_settings($instance);
  if (!empty($commerce_cart_settings['attribute_widget_title'])) {
    $title = $commerce_cart_settings['attribute_widget_title'];

    // Use the translated customized title if it exists.
    if (!empty($translated_instance['attribute_widget_title'])) {
      $title = $translated_instance['attribute_widget_title'];
    }
  }
  return check_plain($title);
}