You are here

function commerce_reorder_handler_field_commerce_reorder_button::options_form in Commerce Reorder 7.2

Same name and namespace in other branches
  1. 7 includes/views/handlers/commerce_reorder_handler_field_commerce_reorder_button.inc \commerce_reorder_handler_field_commerce_reorder_button::options_form()

Default options form provides the label widget that all fields should have.

Overrides views_handler_field::options_form

File

includes/views/handlers/commerce_reorder_handler_field_commerce_reorder_button.inc, line 22

Class

commerce_reorder_handler_field_commerce_reorder_button

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['reorder_button_label'] = array(
    '#type' => 'textfield',
    '#title' => t('Reorder button label'),
    '#default_value' => $this->options['reorder_button_label'],
  );
  $form['redirect'] = array(
    '#type' => 'checkbox',
    '#title' => t('Redirect after reorder'),
    '#default_value' => $this->options['redirect'],
  );
  $form['redirect_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Target URL to redirect after reorder'),
    '#default_value' => $this->options['redirect_url'],
    '#description' => t('Tokens are supported. For instance you may use <strong></strong><code>checkout/[site:current-cart-order:order-id]/review</code></strong> to go directly to the review step.'),
    '#dependency' => array(
      'edit-options-redirect' => array(
        TRUE,
      ),
    ),
  );
  $types = commerce_customer_profile_types();
  $copy_profile_options = array();
  foreach ($types as $type => $type_data) {
    $copy_profile_options[$type] = t($type_data['name']);
  }
  $form['suppress_cart_messages'] = array(
    '#type' => 'checkbox',
    '#title' => t('Suppress add to cart messages'),
    '#default_value' => $this->options['suppress_cart_messages'],
    '#description' => t('Enable this to hide any status message updates that occur during the order copy. Will still allow errors and warnings to come through.'),
  );
  $form['copy_profiles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Copy customer profiles to the new order'),
    '#description' => t('The selected profiles will be copied to the new order.'),
    '#options' => $copy_profile_options,
    '#default_value' => $this->options['copy_profiles'],
  );
  $source_options = array(
    'order' => t('Original order'),
  );
  if (module_exists('commerce_addressbook')) {
    $source_options['addressbook'] = t('Address book defaults');
  }
  $form['copy_profiles_source'] = array(
    '#title' => t('Copy customer profile information from'),
    '#type' => 'radios',
    '#default_value' => $this->options['copy_profiles_source'],
    '#options' => $source_options,
    '#states' => array(
      'visible' => array(
        ':input[name*="[copy_profiles]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
    '#description' => t('Profiles can be copied from the original order or from the address book if available.'),
  );
}