You are here

public function commerce_discount_handler_field_commerce_discount_analytics::render in Commerce Discount 7

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

includes/views/handlers/commerce_discount_handler_field_commerce_discount_analytics.inc, line 27
Views field handler integration for the Commerce Discount Usage module.

Class

commerce_discount_handler_field_commerce_discount_analytics
Field handler to show commerce discount operations in dropbutton.

Code

public function render($values) {

  // Wrap the discount entity found.
  $wrapper = entity_metadata_wrapper('commerce_discount', entity_load_single('commerce_discount', $this
    ->get_value($values, 'discount_id')));
  return theme('item_list', array(
    'items' => array(
      $wrapper->discount_usage_limit
        ->value() ? t('@max available', array(
        '@max' => $wrapper->discount_usage_limit
          ->value(),
      )) : t('Unlimited'),
      $wrapper->discount_usage_per_person
        ->value() ? t('Limit @max per customer', array(
        '@max' => $wrapper->discount_usage_per_person
          ->value(),
      )) : t('Unlimited usage per customer'),
      t('Used @used times', array(
        '@used' => commerce_discount_usage_get_usage($wrapper->name
          ->value()),
      )),
    ),
  ));
}