public function Invoice::getSubtotalPrice in Commerce Invoice 8.2
Gets the invoice subtotal price.
Represents a sum of all invoice item totals.
Return value
\Drupal\commerce_price\Price|null The invoice subtotal price, or NULL.
Overrides InvoiceInterface::getSubtotalPrice
File
- src/
Entity/ Invoice.php, line 377
Class
- Invoice
- Defines the invoice entity class.
Namespace
Drupal\commerce_invoice\EntityCode
public function getSubtotalPrice() {
/** @var \Drupal\commerce_price\Price $subtotal_price */
$subtotal_price = NULL;
foreach ($this
->getItems() as $invoice_item) {
if ($invoice_item_total = $invoice_item
->getTotalPrice()) {
$subtotal_price = $subtotal_price ? $subtotal_price
->add($invoice_item_total) : $invoice_item_total;
}
}
return $subtotal_price;
}