public function OrderItem::getAdjustments in Commerce Core 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 OrderItem::getAdjustments()
- OrderItem::applyAdjustments in modules/
order/ src/ Entity/ OrderItem.php - Applies adjustments to the given price.
File
- modules/
order/ src/ Entity/ OrderItem.php, line 157
Class
- OrderItem
- Defines the order item entity class.
Namespace
Drupal\commerce_order\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;
}