Drupal Commerce Line Item temporary delete? I need to temporarily remove a few line items from an order.  I can remove them well enough, but they won't add back.  There aren't any error messages in watchdog, the error log, or on screen.

Here is the code I have currently:

$orderWrapper = entity_metadata_wrapper('commerce_order', $order);
$removedLineItems = array();

// Loop over each line item on the order.
foreach ($orderWrapper-&gt;commerce_line_items as $delta =&gt; $lineItemWrapper)
{
  $product = $lineItemWrapper-&gt;commerce_product-&gt;value(); // Get id to pass to line_item_delete

  if ($product-&gt;some_field[LANGUAGE_NONE][0]['value'] !== 'some condition')
  {
    $lineItem = commerce_line_item_load($lineItemWrapper-&gt;getIdentifier());
    $removedLineItems[] = $lineItem;

    commerce_line_item_delete($lineItemWrapper-&gt;getIdentifier());
    unset($orderWrapper-&gt;commerce_line_items[$delta]);
  }
}
commerce_order_save($order);


// Run some other code on $order
somePlugin_someFunc($order);


// Add back items removed for package calculation
if (count($removedLineItems) &gt; 0)
{
  foreach ($removedLineItems as $lineItem)
  {
    commerce_line_item_save($lineItem);

    $orderWrapper-&gt;commerce_line_items[] = $lineItem;
  }

  commerce_order_save($order);
}


Anyone have an alterative to the above?
Turned out the issue was simpler than I thought.  If you think about the field between line_items and orders as a reference, it makes sense to just remove that reference, save the order, than re-add it later.  I assume the issue was arising that Drupal didn't like deleting than recreating the exact same line_item, so if it isn't ever deleted, than the reference can just be updated.