You are here

function uc_cart_cart_settings_form in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart.module \uc_cart_cart_settings_form()
  2. 6.2 uc_cart/uc_cart.admin.inc \uc_cart_cart_settings_form()

General settings for the shopping cart.

See also

uc_cart_cart_settings_form_validate()

1 string reference to 'uc_cart_cart_settings_form'
uc_cart_menu in uc_cart/uc_cart.module
Implements hook_menu().

File

uc_cart/uc_cart.admin.inc, line 15
Cart administration menu items.

Code

function uc_cart_cart_settings_form($form, &$form_state) {

  // Put fieldsets into vertical tabs.
  $form['cart-settings'] = array(
    '#type' => 'vertical_tabs',
    '#attached' => array(
      'js' => array(
        'vertical-tabs' => drupal_get_path('module', 'uc_cart') . '/uc_cart.admin.js',
      ),
    ),
  );
  $form['general'] = array(
    '#type' => 'fieldset',
    '#title' => t('Basic settings'),
    '#group' => 'cart-settings',
  );
  $panes = uc_cart_cart_pane_list(NULL);
  $form['general']['panes'] = array(
    '#theme' => 'uc_pane_sort_table',
    '#pane_prefix' => 'uc_cap',
    '#draggable' => 'uc-cart-pane-weight',
  );
  foreach ($panes as $id => $pane) {
    $form['general']['panes'][$id]['uc_cap_' . $id . '_enabled'] = array(
      '#type' => 'checkbox',
      '#title' => check_plain($pane['title']),
      '#default_value' => variable_get('uc_cap_' . $pane['id'] . '_enabled', $pane['enabled']),
    );
    $form['general']['panes'][$id]['uc_cap_' . $id . '_weight'] = array(
      '#type' => 'weight',
      '#delta' => 10,
      '#default_value' => variable_get('uc_cap_' . $pane['id'] . '_weight', $pane['weight']),
      '#attributes' => array(
        'class' => array(
          'uc-cart-pane-weight',
        ),
      ),
    );
  }
  $form['general']['uc_cart_add_item_msg'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display a message when a customer adds an item to their cart.'),
    '#default_value' => variable_get('uc_cart_add_item_msg', TRUE),
  );
  $form['general']['uc_add_item_redirect'] = array(
    '#type' => 'textfield',
    '#title' => t('Add to cart redirect'),
    '#description' => t('Enter the page to redirect to when a customer adds an item to their cart, or <none> for no redirect.'),
    '#default_value' => variable_get('uc_add_item_redirect', 'cart'),
    '#size' => 32,
    '#field_prefix' => url(NULL, array(
      'absolute' => TRUE,
    )) . (variable_get('clean_url', 0) ? '' : '?q='),
  );
  $form['general']['uc_cart_empty_button'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show an "Empty cart" button on the cart page.'),
    '#default_value' => variable_get('uc_cart_empty_button', FALSE),
  );
  $form['general']['uc_minimum_subtotal'] = array(
    '#type' => 'uc_price',
    '#title' => t('Minimum order subtotal'),
    '#description' => t('Customers will not be allowed to check out if the subtotal of items in their cart is less than this amount.'),
    '#default_value' => variable_get('uc_minimum_subtotal', 0),
  );
  $form['lifetime'] = array(
    '#type' => 'fieldset',
    '#title' => t('Cart lifetime'),
    '#description' => t('Set the length of time that products remain in the cart. Cron must be running for this feature to work.'),
    '#group' => 'cart-settings',
  );
  $durations = array(
    'singular' => array(
      'minutes' => t('minute'),
      'hours' => t('hour'),
      'days' => t('day'),
      'weeks' => t('week'),
      'years' => t('year'),
    ),
    'plural' => array(
      'minutes' => t('minutes'),
      'hours' => t('hours'),
      'days' => t('days'),
      'weeks' => t('weeks'),
      'years' => t('years'),
    ),
  );
  $form['lifetime']['anonymous'] = array(
    '#type' => 'fieldset',
    '#title' => t('Anonymous users'),
    '#attributes' => array(
      'class' => array(
        'uc-inline-form',
        'clearfix',
      ),
    ),
  );
  $form['lifetime']['anonymous']['uc_cart_anon_duration'] = array(
    '#type' => 'select',
    '#title' => t('Duration'),
    '#options' => drupal_map_assoc(range(1, 60)),
    '#default_value' => variable_get('uc_cart_anon_duration', '4'),
  );
  $form['lifetime']['anonymous']['uc_cart_anon_unit'] = array(
    '#type' => 'select',
    '#title' => t('Units'),
    '#options' => array(
      'minutes' => t('Minute(s)'),
      'hours' => t('Hour(s)'),
      'days' => t('Day(s)'),
      'weeks' => t('Week(s)'),
      'years' => t('Year(s)'),
    ),
    '#default_value' => variable_get('uc_cart_anon_unit', 'hours'),
  );
  $form['lifetime']['authenticated'] = array(
    '#type' => 'fieldset',
    '#title' => t('Authenticated users'),
    '#attributes' => array(
      'class' => array(
        'uc-inline-form',
        'clearfix',
      ),
    ),
  );
  $form['lifetime']['authenticated']['uc_cart_auth_duration'] = array(
    '#type' => 'select',
    '#title' => t('Duration'),
    '#options' => drupal_map_assoc(range(1, 60)),
    '#default_value' => variable_get('uc_cart_auth_duration', '1'),
  );
  $form['lifetime']['authenticated']['uc_cart_auth_unit'] = array(
    '#type' => 'select',
    '#title' => t('Units'),
    '#options' => array(
      'hours' => t('Hour(s)'),
      'days' => t('Day(s)'),
      'weeks' => t('Week(s)'),
      'years' => t('Year(s)'),
    ),
    '#default_value' => variable_get('uc_cart_auth_unit', 'years'),
  );
  $form['continue_shopping'] = array(
    '#type' => 'fieldset',
    '#title' => t('Continue shopping element'),
    '#description' => t('These settings control the <em>continue shopping</em> option on the cart page.'),
    '#group' => 'cart-settings',
  );
  $form['continue_shopping']['uc_continue_shopping_type'] = array(
    '#type' => 'radios',
    '#title' => t('<em>Continue shopping</em> element'),
    '#options' => array(
      'link' => t('Text link'),
      'button' => t('Button'),
      'none' => t('Do not display'),
    ),
    '#default_value' => variable_get('uc_continue_shopping_type', 'link'),
  );
  $form['continue_shopping']['uc_continue_shopping_use_last_url'] = array(
    '#type' => 'checkbox',
    '#title' => t('Make <em>continue shopping</em> go back to the last item that was added to the cart.'),
    '#description' => t('If this is disabled or the item is unavailable, the URL specified below will be used.'),
    '#default_value' => variable_get('uc_continue_shopping_use_last_url', TRUE),
  );
  $form['continue_shopping']['uc_continue_shopping_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Default <em>continue shopping</em> destination'),
    '#default_value' => variable_get('uc_continue_shopping_url', ''),
    '#size' => 32,
    '#field_prefix' => url(NULL, array(
      'absolute' => TRUE,
    )) . (variable_get('clean_url', 0) ? '' : '?q='),
  );
  $form['breadcrumb'] = array(
    '#type' => 'fieldset',
    '#title' => t('Cart breadcrumb'),
    '#description' => t('Drupal automatically adds a <em>Home</em> breadcrumb to the cart page, or you can use these settings to specify a custom breadcrumb.'),
    '#group' => 'cart-settings',
  );
  $form['breadcrumb']['uc_cart_breadcrumb_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Cart page breadcrumb text'),
    '#description' => t('Leave blank to use the default <em>Home</em> breadcrumb.'),
    '#default_value' => variable_get('uc_cart_breadcrumb_text', ''),
  );
  $form['breadcrumb']['uc_cart_breadcrumb_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Cart page breadcrumb destination'),
    '#default_value' => variable_get('uc_cart_breadcrumb_url', ''),
    '#size' => 32,
    '#field_prefix' => url(NULL, array(
      'absolute' => TRUE,
    )) . (variable_get('clean_url', 0) ? '' : '?q='),
  );
  return system_settings_form($form);
}