You are here

function _commerce_file_license_property_combine_values in Commerce File 7

Combines 2 values of the same property

  • provides ability to add numbers, NULLs, unlimited values
1 call to _commerce_file_license_property_combine_values()
_commerce_file_license_property_merge in ./commerce_file.module
Merge one or more property data arrays into the first

File

./commerce_file.module, line 469
Provides integration of file licenses with Commerce

Code

function _commerce_file_license_property_combine_values($a, $b, $aggregated = FALSE, $unlimited_value = COMMERCE_FILE_FIELD_UNLIMITED) {
  if (!isset($a)) {
    return $b;
  }
  if (!isset($b)) {
    return $a;
  }

  // unlimited overrides all to unlimited
  if ($a === $unlimited_value || $b === $unlimited_value) {
    return $unlimited_value;
  }

  // override previous
  if (empty($aggregated)) {
    return $b;
  }

  // aggregate
  return $a + $b;
}