function commerce_paypal_wps_form_commerce_checkout_form_alter in Commerce PayPal 7
Same name and namespace in other branches
- 7.2 modules/wps/commerce_paypal_wps.module \commerce_paypal_wps_form_commerce_checkout_form_alter()
Implements hook_form_FORM_ID_alter().
File
- modules/
wps/ commerce_paypal_wps.module, line 148 - Implements PayPal Website Payments Standard in Drupal Commerce checkout.
Code
function commerce_paypal_wps_form_commerce_checkout_form_alter(&$form, &$form_state) {
// If this checkout form contains the payment method radios...
if (!empty($form['commerce_payment']['payment_method']['#options'])) {
// Loop over its options array looking for a PayPal WPS option.
foreach (array_keys($form['commerce_payment']['payment_method']['#options']) as $key) {
list($method_id, $rule_name) = explode('|', $key);
// If we find PayPal WPS, include its CSS on the form and exit the loop.
if ($method_id == 'paypal_wps') {
$form['commerce_payment']['payment_method']['#attached']['css'][] = drupal_get_path('module', 'commerce_paypal_wps') . '/theme/commerce_paypal_wps.theme.css';
break;
}
}
}
}