function commerce_cardonfile_add_page in Commerce Card on File 7.2
Menu callback: displays the add card page.
If there are multiple CoF payment methods available, show a list and require the user to select one. Otherwise redirect to the add form.
1 string reference to 'commerce_cardonfile_add_page'
- commerce_cardonfile_menu in ./
commerce_cardonfile.module - Implements hook_menu().
File
- includes/
commerce_cardonfile.pages.inc, line 21 - User page callbacks and forms for Commerce Card on File.
Code
function commerce_cardonfile_add_page() {
$account = menu_get_object('user');
$create_implements = commerce_cardonfile_payment_method_implements('create callback');
$content = array();
foreach ($create_implements as $method_id => $method_function) {
$payment_method_instances = _commerce_cardonfile_payment_method_instances($method_id);
foreach ($payment_method_instances as $instance_id => $payment_method) {
$path = 'user/' . $account->uid . '/cards/add/' . drupal_hash_base64($instance_id);
$item = menu_get_item($path);
if ($item['access']) {
$content[] = $item;
}
}
}
// Bypass the user/%user/cards/add listing if only one payment method is
// available.
if (count($content) == 1) {
$item = array_shift($content);
drupal_goto($item['href']);
}
return theme('card_add_list', array(
'content' => $content,
));
}