You are here

function uc_product_actions_form_builder in Ubercart Product Actions 6

Same name and namespace in other branches
  1. 7 uc_product_actions.module \uc_product_actions_form_builder()

Build the action form.

8 calls to uc_product_actions_form_builder()
uc_product_actions_update_active_action_form in ./uc_product_actions.module
'Enable/disable stock tracking' action.
uc_product_actions_update_cost_action_form in ./uc_product_actions.module
'Modify product cost' action.
uc_product_actions_update_default_qty_action_form in ./uc_product_actions.module
'Modify default quantity to add to cart' action.
uc_product_actions_update_list_price_action_form in ./uc_product_actions.module
'Modify product list price' action.
uc_product_actions_update_sell_price_action_form in ./uc_product_actions.module
'Modify product sell price' action.

... See full list

File

./uc_product_actions.module, line 289

Code

function uc_product_actions_form_builder($action) {
  $action_str = str_replace('_', ' ', $action);
  if (($action == 'stock' || $action == 'threshold' || $action == 'active') && !module_exists('uc_stock')) {
    drupal_set_message(t('You must first enable the Stock module before using that operation.'), 'warning');
    drupal_goto($_GET['q']);
  }
  if ($action == 'active') {
    $form['active_change'] = array(
      '#title' => t('Track stock levels'),
      '#type' => 'radios',
      '#options' => array(
        t('off'),
        t('on'),
      ),
    );
    $form['active_method'] = array(
      '#type' => 'hidden',
      '#value' => 'off_on',
    );
  }
  else {
    $form[$action . '_method'] = array(
      '#title' => t('Method to modify the ' . $action_str),
      '#type' => 'select',
      '#options' => array(
        'percentage' => t('Percentage'),
        'difference' => t('Difference'),
        'absolute' => t('Absolute'),
      ),
      '#multiple' => FALSE,
      '#description' => t('Modify the ' . $action_str . ' by a percentage, a difference, or set to an absolute value.'),
    );
    $form[$action . '_change'] = array(
      '#title' => t('Value'),
      '#type' => 'textfield',
      '#size' => 15,
      '#description' => t('Enter a positive or negative numeric value for changing the ' . $action_str . ' by the selected method. Note: for prices, the result will be rounded according to your store settings. For stock, values will be rounded to the nearest integer.'),
      '#default_value' => '',
    );
  }
  return $form;
}