You are here

public function Invoice::removeItem in Commerce Invoice 8.2

Removes an invoice item.

Parameters

\Drupal\commerce_invoice\Entity\InvoiceItemInterface $invoice_item: The invoice item.

Return value

$this

Overrides InvoiceInterface::removeItem

File

src/Entity/Invoice.php, line 262

Class

Invoice
Defines the invoice entity class.

Namespace

Drupal\commerce_invoice\Entity

Code

public function removeItem(InvoiceItemInterface $invoice_item) {
  $index = $this
    ->getItemIndex($invoice_item);
  if ($index !== FALSE) {
    $this
      ->get('invoice_items')
      ->offsetUnset($index);
    $this
      ->recalculateTotalPrice();
  }
  return $this;
}