You are here

function commerce_shipping_line_item_delete in Commerce Shipping 7

Deletes a line item from an order.

Parameters

$order: The order to delete from.

$line_item_id: The ID of the product line item to delete from the order.

$skip_save: TRUE to skip saving the order after deleting the line item; used when the order would otherwise be saved or to delete multiple product line items from the order and then save.

Return value

The order with the matching line item deleted from the line item reference field.

File

./commerce_shipping.module, line 358
Defines the shipping system and checkout integration.

Code

function commerce_shipping_line_item_delete($order, $line_item_id, $skip_save = FALSE) {

  // Remove the line item from the line item reference field.
  $order = commerce_entity_reference_delete('commerce_order', $order, 'commerce_line_items', $line_item_id);

  // Delete the actual line item.
  commerce_line_item_delete($line_item_id);
  if ($skip_save == FALSE) {
    commerce_order_save($order);
  }
  return $order;
}