function uc_pma_form_alter in Ubercart Payment Method Adjustments 6
Same name and namespace in other branches
- 7 uc_pma.module \uc_pma_form_alter()
Implementation of hook_form_alter().
File
- ./
uc_pma.module, line 41 - This module hooks into a few different parts of Ubercart to allow store administrators to associate a fee or discount with payment methods.
Code
function uc_pma_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'uc_payment_methods_form') {
$form['methods_info']['#value'] .= '<div>' . t('The adjustment field can be used to associate a fee or discount with a payment method. Specify a value that is a flat amount or a percentage of the subtotal to be added or subtracted when a payment method is chosen at checkout. Examples: 3%, 1.00, -5.5%, -2') . '</div><br />';
$form['pmtable']['#theme'] = 'uc_pma_payment_method_table';
foreach (element_children($form['pmtable']) as $method_id) {
$form['pmtable'][$method_id]['uc_payment_method_' . $method_id . '_adjustment'] = array(
'#type' => 'textfield',
'#summary callback' => 'summarize_null',
'#default_value' => variable_get('uc_payment_method_' . $method_id . '_adjustment', ''),
'#size' => '9',
);
}
}
elseif ($form_id == 'uc_cart_checkout_form') {
foreach ($form['panes']['payment']['payment_method']['#options'] as $key => $value) {
$adjustment = variable_get('uc_payment_method_' . $key . '_adjustment', '');
if (!empty($adjustment)) {
$form['panes']['payment']['payment_method']['#options'][$key] .= '<div class="description" style="padding-left: 2.5em;">' . payment_method_adjustment_description($key) . '</div>';
}
}
drupal_add_js(drupal_get_path('module', 'uc_pma') . '/uc_pma.js');
drupal_add_js("\$(document).ready( function () { update_method_line_item('" . $form['panes']['payment']['payment_method']['#default_value'] . "'); } );", 'inline');
}
}