You are here

public function AdjustmentTransformer::roundAdjustments in Commerce Core 8.2

Rounds adjustments to their currency precision.

For example, USD adjustments will be rounded to 2 decimals.

Parameters

\Drupal\commerce_order\Adjustment[] $adjustments: The adjustments.

int $mode: The rounding mode. One of the following constants: PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EVEN, PHP_ROUND_HALF_ODD.

Return value

\Drupal\commerce_order\Adjustment[] The rounded adjustments.

Overrides AdjustmentTransformerInterface::roundAdjustments

1 call to AdjustmentTransformer::roundAdjustments()
AdjustmentTransformer::processAdjustments in modules/order/src/AdjustmentTransformer.php
Combines, sorts, and rounds the given adjustments.

File

modules/order/src/AdjustmentTransformer.php, line 100

Class

AdjustmentTransformer

Namespace

Drupal\commerce_order

Code

public function roundAdjustments(array $adjustments, $mode = PHP_ROUND_HALF_UP) {
  foreach ($adjustments as $index => $adjustment) {
    $adjustments[$index] = $this
      ->roundAdjustment($adjustment, $mode);
  }
  return $adjustments;
}