You are here

function commerce_cart_field_formatter_settings_summary in Commerce Core 7

Implements hook_field_formatter_settings_summary().

File

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

Code

function commerce_cart_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = array_merge(field_info_formatter_settings($display['type']), $display['settings']);
  $summary = array();
  if ($display['type'] == 'commerce_cart_add_to_cart_form') {
    $button_text = !empty($settings['button_text']) ? filter_xss($settings['button_text'], array()) : t('Add to cart');
    $translated_instance = commerce_i18n_object('field_instance', $instance);
    if (!empty($translated_instance['add_to_cart_form-button_text-' . $view_mode])) {
      $button_text = $translated_instance['add_to_cart_form-button_text-' . $view_mode] . ' (' . t('translated') . ')';
    }
    $summary = array(
      t('Button text: !text', array(
        '!text' => $button_text,
      )),
      t('Quantity widget: !status', array(
        '!status' => !empty($settings['show_quantity']) ? t('Enabled') : t('Disabled'),
      )),
      t('Default quantity: @quantity', array(
        '@quantity' => $settings['default_quantity'],
      )),
      t('Combine like items: !status', array(
        '!status' => !empty($settings['combine']) ? t('Enabled') : t('Disabled'),
      )),
      t('!visibility attributes on single product forms.', array(
        '!visibility' => !empty($settings['show_single_product_attributes']) ? t('Showing') : t('Hiding'),
      )),
    );
    if (count(commerce_product_line_item_types()) > 1) {
      $type = !empty($settings['line_item_type']) ? $settings['line_item_type'] : 'product';
      $summary[] = t('Add to Cart line item type: @type', array(
        '@type' => commerce_line_item_type_get_name($type),
      ));
    }
  }
  return implode('<br />', $summary);
}