You are here

public function Invoice::addItem in Commerce Invoice 8.2

Adds an invoice item.

Parameters

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

Return value

$this

Overrides InvoiceInterface::addItem

File

src/Entity/Invoice.php, line 253

Class

Invoice
Defines the invoice entity class.

Namespace

Drupal\commerce_invoice\Entity

Code

public function addItem(InvoiceItemInterface $invoice_item) {
  $this
    ->get('invoice_items')
    ->appendItem($invoice_item);
  $this
    ->recalculateTotalPrice();
  return $this;
}