You are here

function commerce_kickstart_configure_store_form in Commerce Kickstart 7.2

Task callback: returns the form allowing the user to add example store content on install.

File

./commerce_kickstart.install, line 123
Installation code for Commerce Kickstart.

Code

function commerce_kickstart_configure_store_form() {
  include_once DRUPAL_ROOT . '/includes/iso.inc';
  drupal_set_title(st('Configure store'));
  $form['country'] = array(
    '#type' => 'fieldset',
    '#title' => st('Country'),
  );
  $form['country']['country_list'] = array(
    '#title' => t('Default store country'),
    '#description' => t('Services specific to the selected country will be installed if they exist.'),
    '#options' => _country_get_predefined_list(),
    '#type' => 'select',
    '#default_value' => variable_get('site_default_country'),
    // This field is not required when installing through drush.
    '#required' => !drupal_is_cli(),
  );

  // Prepare all the options for sample content.
  $options = array(
    '1' => st('Yes'),
    '0' => st('No'),
  );
  $form['functionality'] = array(
    '#type' => 'fieldset',
    '#title' => st('Functionality'),
  );
  $form['functionality']['install_demo_store'] = array(
    '#type' => 'radios',
    '#title' => st('Do you want to install the demo store?'),
    '#description' => st('Shows you everything Commerce Kickstart can do. Includes a custom theme, sample content and products.'),
    '#options' => $options,
    '#default_value' => '1',
  );
  $form['functionality']['notice'] = array(
    '#type' => 'item',
    '#markup' => '<p>' . t('<strong>Important</strong>: Once installed, products type cannot be deleted. Not recommended for development.') . '</p>',
    '#attributes' => array(
      'style' => 'clear: both;',
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="install_demo_store"]' => array(
          'value' => '1',
        ),
      ),
    ),
  );
  $form['localization'] = array(
    '#type' => 'fieldset',
    '#title' => st('Localization'),
  );
  $form['localization']['install_localization'] = array(
    '#type' => 'radios',
    '#title' => st('Do you want to be able to translate the interface of your store?'),
    '#options' => $options,
    '#default_value' => '0',
  );
  $options_selection = array(
    'anonymous_checkout' => 'Allow checkout for <strong>anonymous users</strong>.',
    'merchandising' => 'Additional <strong>blocks</strong> for featuring specific content.',
    'slideshow' => 'Frontpage <strong>slideshow</strong>.',
    'menus' => 'Custom <strong>admin menu</strong> designed for store owners.',
    'blog' => '<strong>Blog</strong> functionality.',
    'social' => '<strong>Social</strong> logins and links for sharing products via social networks.',
    'zoom_cloud' => '<strong>Zoom & Gallery</strong> mode for products.',
  );
  $form['functionality']['extras'] = array(
    '#type' => 'checkboxes',
    '#options' => $options_selection,
    '#title' => t("Install additional functionality"),
    '#states' => array(
      'visible' => array(
        ':input[name="install_demo_store"]' => array(
          'value' => '0',
        ),
      ),
    ),
  );

  // Build a currency options list from all defined currencies.
  $options = array();
  foreach (commerce_currencies(FALSE, TRUE) as $currency_code => $currency) {
    $options[$currency_code] = t('@code - !name', array(
      '@code' => $currency['code'],
      '@symbol' => $currency['symbol'],
      '!name' => $currency['name'],
    ));
    if (!empty($currency['symbol'])) {
      $options[$currency_code] .= ' - ' . check_plain($currency['symbol']);
    }
  }
  $form['commerce_default_currency_wrapper'] = array(
    '#type' => 'fieldset',
    '#title' => st('Currency'),
  );
  $form['commerce_default_currency_wrapper']['commerce_default_currency'] = array(
    '#type' => 'select',
    '#title' => t('Default store currency'),
    '#options' => $options,
    '#default_value' => commerce_default_currency(),
  );

  // Prepare all the options for sample content.
  $options = array(
    'none' => st("No sample tax rate."),
    'us' => st('US - Sales taxes displayed in checkout'),
    'europe' => st('European - Inclusive tax rates (VAT)'),
  );
  $form['commerce_kickstart_tax_wrapper'] = array(
    '#type' => 'fieldset',
    '#title' => st('Tax Rate'),
  );
  $form['commerce_kickstart_tax_wrapper']['commerce_kickstart_choose_tax_country'] = array(
    '#type' => 'radios',
    '#title' => st('Tax rate examples'),
    '#description' => st('Example tax rates will be created in this style.'),
    '#options' => $options,
    '#default_value' => key($options),
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => st('Create and Finish'),
    '#weight' => 15,
  );
  return $form;
}