public function Shipment::getAdjustments in Commerce Shipping 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
2 calls to Shipment::getAdjustments()
- Shipment::clearAdjustments in src/
Entity/ Shipment.php - Removes all adjustments that belong to the shipment.
- Shipment::getAdjustedAmount in src/
Entity/ Shipment.php - Gets the adjusted amount.
File
- src/
Entity/ Shipment.php, line 370
Class
- Shipment
- Defines the shipment entity class.
Namespace
Drupal\commerce_shipping\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;
}