You are here

function commerce_cardonfile_handler_field_card_exp::render in Commerce Card on File 7.2

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

includes/views/handlers/commerce_cardonfile_handler_field_card_exp.inc, line 8

Class

commerce_cardonfile_handler_field_card_exp
Field handler to present the card expiration date.

Code

function render($values) {
  if (!isset($this->entities[$this->view->row_index])) {
    return '';
  }
  $card = $this->entities[$this->view->row_index];
  $wrapper = entity_metadata_wrapper('commerce_cardonfile', $card);
  $output = $wrapper->card_exp
    ->value();
  if (!commerce_cardonfile_validate_card_expiration($card)) {

    // The card has expired, add visual cues.
    $output = '<div class="card-expired">' . $output . '</div>';
    $output .= '<div class="card-expired-description">' . t('Expired') . '</div>';
  }
  return $output;
}