You are here

function commerce_donate_checkout_pane_settings_form in Commerce Donate 7

Configure the donation checkout pane.

File

includes/commerce_donate.checkout_pane.inc, line 11
Contains callback functions for the commerce_donate checkout pane.

Code

function commerce_donate_checkout_pane_settings_form($checkout_pane) {
  $options = array();
  $products = commerce_product_load_multiple(array(), array(
    'type' => 'donation',
    'status' => 1,
  ));
  if (empty($products)) {
    drupal_set_message(t('You must configure at least one donation product in order to accept donations during checkout.'), 'error');
  }
  foreach ($products as $pid => $product) {
    $options[$pid] = $product->title;
  }
  $form['commerce_donate_checkout_pane_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Checkout pane title'),
    '#default_value' => variable_get('commerce_donate_checkout_pane_title', ''),
  );
  $form['commerce_donate_checkout_pane_description'] = array(
    '#type' => 'textarea',
    '#title' => t('Checkout pane description'),
    '#default_value' => variable_get('commerce_donate_checkout_pane_description', ''),
  );
  $form['commerce_donate_checkout_pane_product_id'] = array(
    '#type' => 'select',
    '#title' => t('Donation product'),
    '#options' => $options,
    '#default_value' => variable_get('commerce_donate_checkout_pane_product_id', 0),
    '#description' => t('Donation product to use when adding line item to the cart.'),
  );
  $form['commerce_donate_checkout_pane_override_options'] = array(
    '#type' => 'checkbox',
    '#title' => t('Override available options'),
    '#default_value' => variable_get('commerce_donate_checkout_pane_override_options', FALSE),
  );
  $form['commerce_donate_checkout_pane_donate_amounts'] = array(
    '#type' => 'textarea',
    '#title' => t('Available options'),
    '#description' => t('A list of values that are, by default, available for selection. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and the label is what will be displayed to the user.  For example, "5|5.00"'),
    '#default_value' => variable_get('commerce_donate_checkout_pane_donate_amounts', ''),
    '#states' => array(
      'visible' => array(
        ':input[name="commerce_donate_checkout_pane_override_options"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  return $form;
}