You are here

class RulesDataUIShippingSettings in Commerce Shipping 7

Adds a shipping method settings form to the enabling action.

Hierarchy

Expanded class hierarchy of RulesDataUIShippingSettings

1 string reference to 'RulesDataUIShippingSettings'
commerce_shipping_rules_data_info in ./commerce_shipping.rules.inc
Implements hook_rules_data_info().

File

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

View source
class RulesDataUIShippingSettings extends RulesDataUI implements RulesDataDirectInputFormInterface {
  public static function getDefaultMode() {
    return 'input';
  }
  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;
  }
  public static function render($value) {
    return array();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesDataUI::getTypeInfo public static function Returns the data type and parameter information for the given arguments.
RulesDataUI::renderOptionsLabel public static function Renders the value with a label if an options list is available.
RulesDataUI::selectionForm public static function Provides the selection form for a parameter.
RulesDataUIShippingSettings::getDefaultMode public static function Specifies the default input mode per data type. Overrides RulesDataUI::getDefaultMode
RulesDataUIShippingSettings::inputForm public static function Constructs the direct input form. Overrides RulesDataDirectInputFormInterface::inputForm
RulesDataUIShippingSettings::render public static function Render the configured value. Overrides RulesDataDirectInputFormInterface::render