function uc_recurring_product_feature_form in UC Recurring Payments and Subscriptions 6.2
Same name and namespace in other branches
- 7.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_feature in modules/
uc_recurring_product/ uc_recurring_product.module - Implementation of hook_product_feature().
File
- modules/
uc_recurring_product/ uc_recurring_product.module, line 30 - Add recurring payments/fees to a product. This is imlpemented through Ubercarts product features.
Code
function uc_recurring_product_feature_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', 'module');
if (!empty($feature)) {
$product = uc_recurring_product_fee_load($feature['pfid']);
}
$options = uc_product_get_models($node);
$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' => $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 ($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' => $product->fee_amount == 0 ? $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' => $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' => 'interval-fieldset',
),
);
$form['interval']['initial']['initial_charge_value'] = array(
'#type' => 'select',
'#options' => drupal_map_assoc(uc_range(0, 52)),
'#default_value' => $product->initial_charge_value,
);
$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' => $product->initial_charge_unit,
);
$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' => 'interval-fieldset',
),
);
$form['interval']['regular']['regular_interval_value'] = array(
'#type' => 'select',
'#options' => drupal_map_assoc(uc_range(1, 52)),
'#default_value' => $product->regular_interval_value,
);
$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' => $product->regular_interval_unit,
);
$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 ($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' => $product->number_intervals < 0 ? '' : $product->number_intervals,
'#attributes' => $product->number_intervals < 0 ? array(
'disabled' => 'disabled',
) : array(),
);
return uc_product_feature_form($form);
}