You are here

public function FeedsCommerceProductProcessor::configForm in Commerce Feeds 7

Override parent::configForm().

File

plugins/FeedsCommerceProductProcessor.inc, line 84
Class definition of FeedsCommerceProductProcessor.

Class

FeedsCommerceProductProcessor
Creates products from feed items.

Code

public function configForm(&$form_state) {
  $types = commerce_product_type_get_name();
  array_walk($types, 'check_plain');
  $form = parent::configForm($form_state);
  $form['product_type'] = array(
    '#type' => 'select',
    '#title' => t('Product type'),
    '#description' => t('Select the product type for the products to be created. <strong>Note:</strong> Users with "import !feed_id feeds" permissions will be able to <strong>import</strong> products of the type selected here regardless of the product level permissions. Further, users with "clear !feed_id permissions" will be able to <strong>delete</strong> imported products regardless of their product level permissions.', array(
      '!feed_id' => $this->id,
    )),
    '#options' => $types,
    '#default_value' => $this->config['product_type'],
  );
  $author = user_load($this->config['author']);
  $form['author'] = array(
    '#type' => 'textfield',
    '#title' => t('Author'),
    '#description' => t('Select the author of the products to be created - leave empty to assign "anonymous".'),
    '#autocomplete_path' => 'user/autocomplete',
    '#default_value' => empty($author->name) ? 'anonymous' : check_plain($author->name),
  );
  if (module_exists('commerce_tax')) {
    $inclusive_types = array();
    foreach (commerce_tax_types() as $name => $tax_type) {
      if ($tax_type['display_inclusive']) {
        $inclusive_types[$name] = $tax_type['title'];
      }
    }
    $options = array();
    foreach (commerce_tax_rates() as $name => $tax_rate) {
      if (in_array($tax_rate['type'], array_keys($inclusive_types))) {
        $options[$inclusive_types[$tax_rate['type']]][$name] = $tax_rate['title'];
      }
    }
    $form['tax_rate'] = array(
      '#type' => 'select',
      '#title' => t('Tax rate'),
      '#description' => t('Select a display inclusive tax rate to set on the product prices in import.'),
      '#options' => count($options) == 1 ? reset($options) : $options,
      '#empty_value' => TRUE,
      '#default_value' => !empty($this->config['tax_rate']) ? $this->config['tax_rate'] : '',
    );
  }
  return $form;
}