/**
  * Deletes the line items as indicated by the line item code(s) provided,
  * regardless of where they're found in the line item tree. Automatically
  * re-calculates the line item totals and updates the related transaction. But
  * DOES NOT automatically upgrade the transaction's registrations' final prices (which
  * should probably change because of this).
  * You should call EE_Registration_Processor::calculate_reg_final_prices_per_line_item()
  * after using this, to keep the registration final prices in-sync with the transaction's total.
  * @param EE_Line_Item      $total_line_item of type EEM_Line_Item::type_total
  * @param array|bool|string $line_item_codes
  * @return int number of items successfully removed
  */
 public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE)
 {
     if ($total_line_item->type() != EEM_Line_Item::type_total) {
         EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __('This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso'), '4.6.18');
     }
     do_action('AHEE_log', __FILE__, __FUNCTION__, '');
     // check if only a single line_item_id was passed
     if (!empty($line_item_codes) && !is_array($line_item_codes)) {
         // place single line_item_id in an array to appear as multiple line_item_ids
         $line_item_codes = array($line_item_codes);
     }
     $removals = 0;
     // cycle thru line_item_ids
     foreach ($line_item_codes as $line_item_id) {
         $removals += $total_line_item->delete_child_line_item($line_item_id);
     }
     if ($removals > 0) {
         $total_line_item->recalculate_taxes_and_tax_total();
         return $removals;
     } else {
         return FALSE;
     }
 }
 /**
  * Deletes ALL children of the passed line item
  *
  * @param EE_Line_Item $parent_line_item
  * @return bool
  */
 public static function delete_all_child_items(EE_Line_Item $parent_line_item)
 {
     $deleted = 0;
     foreach ($parent_line_item->children() as $child_line_item) {
         if ($child_line_item instanceof EE_Line_Item) {
             $deleted += EEH_Line_Item::delete_all_child_items($child_line_item);
             if ($child_line_item->ID()) {
                 $child_line_item->delete();
             } else {
                 $parent_line_item->delete_child_line_item($child_line_item->code());
             }
             $deleted++;
         }
     }
     return $deleted;
 }