You are here

public function CommerceFileLicenseEntity::unlink_line_item in Commerce File 7

Remove a line item

Return value

TRUE if the line item was unlinked

File

includes/commerce_file_license.entity.inc, line 587
Provides a base class for CommerceFileLicenseEntity.

Class

CommerceFileLicenseEntity
A Commerce File License entity class.

Code

public function unlink_line_item($line_item_id) {
  $field_name = _commerce_file_get_field_names('license_line_items');
  $line_item_field = $this
    ->_get_field_value($field_name);
  $changed = FALSE;
  foreach ($line_item_field as $k => $line_item_field_item) {
    if ($line_item_field_item->line_item_id == $line_item_id) {
      unset($line_item_field[$k]);
      $changed = TRUE;
    }
  }
  if ($changed) {
    $this
      ->_set_field_value($field_name, $line_item_field);
  }
  return $changed;
}