You are here

function uc_dropdown_attributes_order_attribute_display in Dropdown Attributes 8

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

Alter display of attributes on the order page.

Parameters

array $attributes: Array of attribute dependency objects.

array &$form_attributes: Attributes part of the product form.

array $form_state_attributes: Attributes part of the product form_state.

1 call to uc_dropdown_attributes_order_attribute_display()
_uc_dropdown_attributes_order_product_kit_build in ./uc_dropdown_attributes.module
Form build for product kits for the order page.

File

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

Code

function uc_dropdown_attributes_order_attribute_display($attributes, &$form_attributes, $form_state_attributes, $form_state) {
  foreach ($attributes as $attribute) {
    if ($attribute->parent_aid == 0) {
      continue;
    }
    $parent_value = $form_state_attributes[$attribute->parent_aid];
    if ($parent_value) {

      // A value has been entered in parent attribute.
      $values = unserialize($attribute->parent_values);
      if (!in_array($parent_value, $values)) {
        uc_dropdown_attributes_hide_attribute($form_attributes, $attribute->aid);
        if ($attribute->required) {
          uc_dropdown_attributes_clear_input($form_attributes, $form_state_attributes, $attribute->aid);
        }
      }
    }
    else {
      uc_dropdown_attributes_hide_attribute($form_attributes, $attribute->aid);
      if ($attribute->required) {
        uc_dropdown_attributes_clear_input($form_attributes, $form_state_attributes, $attribute->aid);
      }
    }
  }
}