You are here

function commerce_price_table_field_presave in Commerce Price Table 7

Implements hook_field_presave().

File

./commerce_price_table.module, line 153

Code

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

  // Convert amounts to integers and serialize data arrays before saving.
  foreach ($items as $delta => $item) {

    // Serialize an existing data array.
    if (isset($item['data']) && is_array($item['data'])) {
      $items[$delta]['data'] = serialize($item['data']);
    }
    if (empty($item['min_qty'])) {
      $items[$delta]['min_qty'] = 0;
    }
    if (empty($item['max_qty'])) {
      $items[$delta]['max_qty'] = 0;
    }
  }
}