You are here

public function Shipment::getAdjustedAmount in Commerce Shipping 8.2

Gets the adjusted amount.

Parameters

string[] $adjustment_types: The adjustment types to include in the adjusted price. Examples: fee, promotion, tax. Defaults to all adjustment types.

Return value

\Drupal\commerce_price\Price|null The adjusted amount, or NULL.

Overrides ShipmentInterface::getAdjustedAmount

File

src/Entity/Shipment.php, line 351

Class

Shipment
Defines the shipment entity class.

Namespace

Drupal\commerce_shipping\Entity

Code

public function getAdjustedAmount(array $adjustment_types = []) {
  $amount = $this
    ->getAmount();
  if (!$amount) {
    return NULL;
  }
  foreach ($this
    ->getAdjustments($adjustment_types) as $adjustment) {
    if (!$adjustment
      ->isIncluded()) {
      $amount = $amount
        ->add($adjustment
        ->getAmount());
    }
  }
  $rounder = \Drupal::service('commerce_price.rounder');
  $amount = $rounder
    ->round($amount);
  return $amount;
}