You are here

function commerce_cardonfile_element_options_list in Commerce Card on File 7.2

Returns an options array for selecting a card on file during checkout

Parameters

$stored_cards: An array of stored card data arrays keyed by card_id.

Return value

An options array for selecting a card on file.

2 calls to commerce_cardonfile_element_options_list()
commerce_cardonfile_form_alter in ./commerce_cardonfile.module
Implements hook_form_alter().
commerce_cardonfile_form_commerce_payment_order_transaction_add_form_alter in ./commerce_cardonfile.module
Implements hook_form_FORM_ID_alter().

File

./commerce_cardonfile.module, line 791
Supports card on file functionality for credit card payment methods by associating card data reference IDs from payment gateways with user accounts.

Code

function commerce_cardonfile_element_options_list($stored_cards) {
  $options = array();
  foreach ($stored_cards as $card_id => $card) {
    $replacements = array(
      '@card' => $card
        ->label(),
      '@card_exp_month' => str_pad($card->card_exp_month, 2, '0', STR_PAD_LEFT),
      '@card_exp_year' => $card->card_exp_year,
    );
    $options[$card_id] = t('@card, Expires @card_exp_month/@card_exp_year', $replacements);
  }

  // Add the special option for adding a new card.
  $options['new'] = t('Use a different credit card');
  return $options;
}