function uc_recurring_product_feature_form in UC Recurring Payments and Subscriptions 7.2
Same name and namespace in other branches
- 6.2 modules/uc_recurring_product/uc_recurring_product.module \uc_recurring_product_feature_form()
Builds the form to display adding or editing a recurring fee feature.
1 string reference to 'uc_recurring_product_feature_form'
- uc_recurring_product_uc_product_feature in modules/
uc_recurring_product/ uc_recurring_product.module - Implements hook_uc_product_feature().
File
- modules/
uc_recurring_product/ uc_recurring_product.module, line 29 - Add recurring payments/fees to a product. This is imlpemented through Ubercarts product features.
Code
function uc_recurring_product_feature_form($form, &$form_state, $node, $feature) {
drupal_add_css(drupal_get_path('module', 'uc_recurring') . '/uc_recurring.css');
drupal_add_js(drupal_get_path('module', 'uc_recurring') . '/uc_recurring.js');
if (!empty($feature)) {
$product = uc_recurring_product_fee_load($feature['pfid']);
}
else {
$product = new StdClass();
}
$options = uc_product_get_models($node->nid);
$form['nid'] = array(
'#type' => 'hidden',
'#value' => $node->nid,
);
$form['model'] = array(
'#type' => 'select',
'#title' => t('Applicable SKU'),
'#description' => t('Select the applicable product model/SKU for this fee.'),
'#options' => $options,
'#default_value' => isset($product->model) ? $product->model : '',
);
$form['fee'] = array(
'#type' => 'fieldset',
'#title' => t('Recurring Fee Amount'),
'#collapsible' => FALSE,
'#description' => t('Specify the amount that is charged on each renewal date.'),
);
$attributes = array();
if (isset($product->fee_amount) && $product->fee_amount == 0) {
$attributes['checked'] = 'checked';
}
$form['fee']['fee_same_product'] = array(
'#type' => 'checkbox',
'#title' => t('Set the recurring fee amount to the same as selling price of the product at the time of purchase.'),
'#attributes' => $attributes,
);
$form['fee']['product_price'] = array(
'#type' => 'hidden',
'#value' => $node->sell_price,
);
$form['fee']['fee_amount'] = array(
'#type' => 'textfield',
'#title' => t('Recurring fee amount'),
'#description' => t('Charge this amount each billing period.<br />The product price is still charged at checkout.'),
'#default_value' => empty($product->fee_amount) ? $node->sell_price : $product->fee_amount,
'#size' => 16,
'#field_prefix' => variable_get('uc_sign_after_amount', FALSE) ? '' : variable_get('uc_currency_sign', '$'),
'#field_suffix' => variable_get('uc_sign_after_amount', FALSE) ? variable_get('uc_currency_sign', '$') : '',
'#attributes' => isset($product->fee_amount) && $product->fee_amount == 0 ? array(
'disabled' => 'disabled',
) : array(),
);
$form['interval'] = array(
'#type' => 'fieldset',
'#title' => t('Payment Interval Settings'),
'#collapsible' => FALSE,
'#description' => t('Remember the product price will be charged at the time of checkout. This section specifies when the recurring amount will be charged.'),
);
$form['interval']['initial'] = array(
'#type' => 'fieldset',
'#title' => t('Initial charge'),
'#collapsible' => FALSE,
'#description' => t('Specify the time to wait to start charging the recurring fee after checkout.'),
'#attributes' => array(
'class' => array(
'interval-fieldset',
),
),
);
$form['interval']['initial']['initial_charge_value'] = array(
'#type' => 'select',
'#title' => t(''),
'#options' => drupal_map_assoc(range(0, 52)),
'#default_value' => isset($product->initial_charge_value) ? $product->initial_charge_value : 1,
);
$form['interval']['initial']['initial_charge_unit'] = array(
'#type' => 'select',
'#options' => array(
'days' => t('day(s)'),
'weeks' => t('week(s)'),
'months' => t('month(s)'),
'years' => t('year(s)'),
),
'#default_value' => isset($product->initial_charge_unit) ? $product->initial_charge_unit : 'months',
);
$form['interval']['regular'] = array(
'#type' => 'fieldset',
'#title' => t('Regular interval'),
'#collapsible' => FALSE,
'#description' => t('Specify the length of the billing period for this fee.'),
'#attributes' => array(
'class' => array(
'interval-fieldset',
),
),
);
$form['interval']['regular']['regular_interval_value'] = array(
'#type' => 'select',
'#options' => drupal_map_assoc(range(1, 52)),
'#default_value' => isset($product->regular_interval_value) ? $product->regular_interval_value : 1,
);
$form['interval']['regular']['regular_interval_unit'] = array(
'#type' => 'select',
'#options' => array(
'days' => t('day(s)'),
'weeks' => t('week(s)'),
'months' => t('month(s)'),
'years' => t('year(s)'),
),
'#default_value' => isset($product->regular_interval_unit) ? $product->regular_interval_unit : 'months',
);
$form['num_interval'] = array(
'#type' => 'fieldset',
'#title' => t('Number of billing periods'),
'#collapsible' => FALSE,
'#description' => t('Specify how many times the recurring fee will be charged.'),
);
$attributes = array();
if (isset($product->number_intervals) && $product->number_intervals < 0) {
$attributes['checked'] = 'checked';
}
$form['num_interval']['unlimited_intervals'] = array(
'#type' => 'checkbox',
'#title' => t('Unlimited rebillings.'),
'#attributes' => $attributes,
);
$form['num_interval']['number_intervals'] = array(
'#type' => 'textfield',
'#title' => t('Number of billing periods'),
'#size' => 16,
'#default_value' => isset($product->number_intervals) ? $product->number_intervals < 0 ? '' : $product->number_intervals : '',
'#attributes' => isset($product->number_intervals) && $product->number_intervals < 0 ? array(
'disabled' => 'disabled',
) : array(),
);
return $form;
}