Re: Re: Re: Well. You rock. I'll get

digitalfrontiersmedia's picture
Offline
Getting busy with the Ubercode.
Joined: 11/08/2008
Juice: 283
Re: Re: Re: Well. You rock. I'll get

Here's another related issue. This appears to occur when entering an order through the administrative backend however it may happen on the storefront, too (I assume so but haven't checked).

A user sees the first Credit Card type option in the dropdown listed and assumes that is the current selection. If that selection matches their actual credit card type, they don't bother to change the selection. Upon saving the order, the cc_type is empty even though something like "Visa" may have appeared in the the dropdown as the "default selection".

I think the solution is in lines 879-885 of uc_credit.module:

    $form['cc_type'] = array(
      '#type' => 'select',
      '#title' => t('Card type'),
      '#options' => $options,
      '#default_value' => $order->payment_details['cc_type'],
    );
  }

Line 883 should check if there is any data in $order->payment_details['cc_type'] and supply a default if there isn't:

      '#default_value' => $order->payment_details['cc_type'] ? $order->payment_details['cc_type'] : t('Visa'), // DFM 1.28.09 ensures the type is not empty

I'm not sure if t('Visa') is truly the correct solution here in case someone has altered the "Card type select box options" in the "Credit card settings" fieldset at /admin/store/settings/payment/edit/methods, but this solves the problem of empty cc_type data.

Is there a better alternative to hardcoding t('Visa') as the default if $order->payment_details['cc_type'] is empty for a new order?

Oddly, I'd previously tried inserting

'#required' => TRUE,

but it seemed to just be ignored. Due to AJAX inserting the field after page load?