public function Order::collectAdjustments in Commerce Core 8.2
Collects all adjustments that belong to the order.
Unlike getAdjustments() which returns only order adjustments, this method returns both order and order 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 OrderInterface::collectAdjustments
See also
\Drupal\commerce_order\AdjustmentTransformerInterface::processAdjustments()
1 call to Order::collectAdjustments()
- Order::recalculateTotalPrice in modules/
order/ src/ Entity/ Order.php - Recalculates the order total price.
File
- modules/
order/ src/ Entity/ Order.php, line 403
Class
- Order
- Defines the order entity class.
Namespace
Drupal\commerce_order\EntityCode
public function collectAdjustments(array $adjustment_types = []) {
$adjustments = [];
foreach ($this
->getItems() as $order_item) {
foreach ($order_item
->getAdjustments($adjustment_types) as $adjustment) {
if ($order_item
->usesLegacyAdjustments()) {
$adjustment = $adjustment
->multiply($order_item
->getQuantity());
}
$adjustments[] = $adjustment;
}
}
foreach ($this
->getAdjustments($adjustment_types) as $adjustment) {
$adjustments[] = $adjustment;
}
return $adjustments;
}