You are here

public static function RulesDataUIShippingSettings::inputForm in Commerce Shipping 7

Constructs the direct input form.

Return value

array The direct input form.

Overrides RulesDataDirectInputFormInterface::inputForm

File

./commerce_shipping.rules.inc, line 141
Rules integration for shipping.

Class

RulesDataUIShippingSettings
Adds a shipping method settings form to the enabling action.

Code

public static function inputForm($name, $info, $settings, RulesPlugin $element) {
  $plugin = str_replace('plugin-', '', $info['shipping_method']);
  $class = commerce_shipping_plugin_get_plugin_class_init('quotes', $plugin);
  if ($class === FALSE) {
    $form[$name]['invalid']['#markup'] = t('Error getting shipping method.');
  }
  else {
    $form[$name]['method_id'] = array(
      '#type' => 'value',
      '#value' => $info['shipping_method'],
    );
    $form[$name]['shipping_label'] = array(
      '#type' => 'textfield',
      '#title' => t('Shipping label'),
      '#description' => t('Customise the shipping label as it would appear for customers'),
      '#default_value' => is_array($settings[$name]) && isset($settings[$name]['shipping_label']) ? $settings[$name]['shipping_label'] : '',
    );
    $form[$name]['settings'] = array();

    // Prepare an array of shipping method settings defaults.
    $rules_settings = !empty($settings[$name]) && isset($settings[$name]['settings']) ? $settings[$name]['settings'] : array();
    $class
      ->settings_form($form[$name]['settings'], $rules_settings);
  }

  /*else {
      $form[$name]['invalid']['#markup'] = t('Invalid shipping method.');
    }*/
  return $form;
}