You are here

function commerce_braintree_commerce_cardonfile_checkout_pane_form_alter in Commerce Braintree 7.3

Same name and namespace in other branches
  1. 7.2 commerce_braintree.module \commerce_braintree_commerce_cardonfile_checkout_pane_form_alter()

Implements hook_commerce_cardonfile_checkout_pane_form_alter().

File

./commerce_braintree.module, line 546
Integrates Braintree Transparent Redirect with Drupal Commerce.

Code

function commerce_braintree_commerce_cardonfile_checkout_pane_form_alter(&$pane, $form, $form_state) {

  // If the form contains TR data, then we should show the credit card
  // form and hide the card on file details.
  if ($form['commerce_payment']['payment_method']['#default_value'] == 'braintree_tr|commerce_payment_braintree_tr' && !empty($form['tr_data'])) {
    $pane['cardonfile']['#access'] = FALSE;
    $pane['credit_card']['#access'] = TRUE;
  }

  // Add the CSS to hide a sole credit card icon if specified.
  if (variable_get('commerce_cardonfile_hide_cc_radio_button', TRUE)) {
    if (count($form['commerce_payment']['payment_method']['#options']) == 1) {
      $form['commerce_payment']['payment_method']['#attached']['css'][] = drupal_get_path('module', 'commerce_cardonfile') . '/theme/commerce_cardonfile.checkout.css';
    }
  }
}