public function Invoice::collectAdjustments in Commerce Invoice 8.2
Collects all adjustments that belong to the invoice.
Unlike getAdjustments() which returns only invoice adjustments, this method returns both invoice and invoice item adjustments.
Important: The returned adjustments are unprocessed, and must be processed before use.
Parameters
string[] $adjustment_types: The adjustment types to include. Examples: fee, promotion, tax. Defaults to all adjustment types.
Return value
\Drupal\commerce_order\Adjustment[] The adjustments.
Overrides InvoiceInterface::collectAdjustments
See also
\Drupal\commerce_order\AdjustmentTransformerInterface::processAdjustments()
1 call to Invoice::collectAdjustments()
- Invoice::recalculateTotalPrice in src/
Entity/ Invoice.php - Recalculates the invoice total price.
File
- src/
Entity/ Invoice.php, line 345
Class
- Invoice
- Defines the invoice entity class.
Namespace
Drupal\commerce_invoice\EntityCode
public function collectAdjustments(array $adjustment_types = []) {
$adjustments = [];
foreach ($this
->getItems() as $invoice_item) {
foreach ($invoice_item
->getAdjustments($adjustment_types) as $adjustment) {
$adjustments[] = $adjustment;
}
}
foreach ($this
->getAdjustments($adjustment_types) as $adjustment) {
$adjustments[] = $adjustment;
}
return $adjustments;
}