There's an API function / entity controller method for deleting line items, but it currently doesn't delete any references to the line item from line item reference fields. The complicating factor here is there isn't a magic query we can execute... it'll be different on every site depending on the name of line item reference fields used. We need to interact with the field API somehow to update the values for the line item reference fields that reference the deleted line item so we know what we need to update and to make a new revision if necessary.

Comments

rszrama’s picture

fwiw, this code should go in commerce_line_item.controller.inc in the class's delete function. I imagine it'd be a part of this foreach loop:

foreach ($line_items as $line_item_id => $line_item) {
  module_invoke_all('commerce_line_item_delete', $line_item);
  field_attach_delete('commerce_line_item', $line_item);
  rules_invoke_event('commerce_line_item_delete', $line_item);
}
rszrama’s picture

Status: Active » Fixed

Done with the function commerce_line_item_commerce_line_item_delete().

http://github.com/rszrama/drupalcommerce/commit/c58655e31b4c1676f15a2403...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.