You are here

function uc_order_condition_count_products_form in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_order/uc_order_workflow.inc \uc_order_condition_count_products_form()

See also

uc_order_condition_count_products()

File

uc_order/uc_order.ca.inc, line 740
This file contains the Conditional Actions hooks and functions necessary to make the order related entity, conditions, events, and actions work.

Code

function uc_order_condition_count_products_form($form_state, $settings = array()) {
  $options = array(
    'all' => t('- All products -'),
  );
  $result = db_query("SELECT nid, model FROM {uc_products} ORDER BY model");
  while ($product = db_fetch_object($result)) {
    $options[$product->nid] = $product->model;
  }
  $form['products'] = array(
    '#type' => 'select',
    '#title' => t('Products'),
    '#options' => $options,
    '#default_value' => isset($settings['products']) ? $settings['products'] : 'all',
    '#description' => check_plain(t('Selecting "- All products -" will override any other selections and returns the total number of products in the order.')),
    '#multiple' => TRUE,
  );
  $form['product_count_value'] = array(
    '#type' => 'textfield',
    '#title' => t('Product count value'),
    '#description' => t('Specify a value to compare the product count against.'),
    '#default_value' => isset($settings['product_count_value']) ? $settings['product_count_value'] : '',
    '#size' => 16,
  );
  $options = array(
    'less' => t('Total is less than specified value.'),
    'less_equal' => t('Total is less than or equal to specified value.'),
    'equal' => t('Total is equal to specified value.'),
    'greater_equal' => t('Total is greater than or equal to specified value.'),
    'greater' => t('Total is greater than specified value.'),
  );
  $form['product_count_comparison'] = array(
    '#type' => 'radios',
    '#title' => t('Product count comparison type'),
    '#options' => $options,
    '#default_value' => isset($settings['product_count_comparison']) ? $settings['product_count_comparison'] : 'greater_equal',
  );
  return $form;
}