You are here

function commerce_pricing_attributes_field_presave in Commerce Pricing Attributes 7

Implements hook_field_presave().

File

./commerce_pricing_attributes.module, line 188

Code

function commerce_pricing_attributes_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {

  // If the instance is a commerce_pricing_attributes field.
  if ($field['type'] == 'commerce_pricing_attributes') {
    foreach ($items as $delta => &$value) {

      // Iterate through the set_details if isset.
      if (!empty($value['set_details'])) {
        foreach ($value['set_details'] as $field_name => &$field) {

          // If the field is not enabled remove from list.
          if (!$field['enabled']) {
            unset($value['set_details'][$field_name]);
          }
        }
      }
    }
  }
}