You are here

function uc_dropdown_attributes_form_uc_order_edit_form_alter in Dropdown Attributes 8

Same name and namespace in other branches
  1. 7 uc_dropdown_attributes.module \uc_dropdown_attributes_form_uc_order_edit_form_alter()

Implements hook_form_FORM_ID_alter() for uc_order_edit_form().

File

./uc_dropdown_attributes.module, line 764
A module for uc_dropdown_attributes.

Code

function uc_dropdown_attributes_form_uc_order_edit_form_alter(&$form, FormStateInterface $form_state) {
  if ($form_state
    ->has('products_action') && $form_state
    ->get('products_action') == 'add_product') {
    $nid = $form['products']['product_controls']['nid']['#value'];
    $product = Node::load($nid);
    if ($product
      ->getType() == 'product_kit') {

      /*
            foreach ($form['product_controls']['sub_products'] as $nid => $product) {
              if (is_numeric($nid)) {
                $type = uc_dropdown_attributes_dependency_type($nid);
                if (!is_null($type)) {
                  uc_dropdown_attributes_order_product_alter($nid, $form['product_controls']['sub_products'][$nid]['attributes'], $type);
                  if (!in_array('_uc_dropdown_attributes_order_product_kit_build',
                    $form['#after_build'])) {

                    $form['#after_build'][]
                      = '_uc_dropdown_attributes_order_product_kit_build';
                  }
                }
              }
            }
      */
    }
    else {
      $type = uc_dropdown_attributes_dependency_type($nid);
      if (!is_null($type)) {
        $values = $form_state
          ->getValues();
        uc_dropdown_attributes_order_product_alter($nid, $form['products']['product_controls']['attributes'], $values['products']['product_controls'], $type);
        switch ($type) {
          case 'node':
            $form['#after_build'][] = '_uc_dropdown_attributes_order_product_build';
            break;
          case 'class':
            $form['#after_build'][] = '_uc_dropdown_attributes_order_class_build';
            break;
        }
      }
    }
  }
}