public function InvoiceItem::getAdjustments in Commerce Invoice 8.2
Gets the adjustments.
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 EntityAdjustableInterface::getAdjustments
1 call to InvoiceItem::getAdjustments()
- InvoiceItem::applyAdjustments in src/
Entity/ InvoiceItem.php - Applies adjustments to the given price.
File
- src/
Entity/ InvoiceItem.php, line 158
Class
- InvoiceItem
- Defines the invoice item entity class.
Namespace
Drupal\commerce_invoice\EntityCode
public function getAdjustments(array $adjustment_types = []) {
/** @var \Drupal\commerce_order\Adjustment[] $adjustments */
$adjustments = $this
->get('adjustments')
->getAdjustments();
// Filter adjustments by type, if needed.
if ($adjustment_types) {
foreach ($adjustments as $index => $adjustment) {
if (!in_array($adjustment
->getType(), $adjustment_types)) {
unset($adjustments[$index]);
}
}
$adjustments = array_values($adjustments);
}
return $adjustments;
}