You are here

public function OrderItem::getAdjustedTotalPrice in Commerce Core 8.2

Gets the adjusted order item total price.

The adjusted total price is calculated by applying the order item's adjustments to the total price. This can include promotions, taxes, etc.

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 order item total price, or NULL.

Overrides OrderItemInterface::getAdjustedTotalPrice

1 call to OrderItem::getAdjustedTotalPrice()
OrderItem::getAdjustedUnitPrice in modules/order/src/Entity/OrderItem.php
Gets the adjusted order item unit price.

File

modules/order/src/Entity/OrderItem.php, line 213

Class

OrderItem
Defines the order item entity class.

Namespace

Drupal\commerce_order\Entity

Code

public function getAdjustedTotalPrice(array $adjustment_types = []) {
  $total_price = $this
    ->getTotalPrice();
  if (!$total_price) {
    return NULL;
  }
  if ($this
    ->usesLegacyAdjustments()) {
    $adjusted_unit_price = $this
      ->getAdjustedUnitPrice($adjustment_types);
    $adjusted_total_price = $adjusted_unit_price
      ->multiply($this
      ->getQuantity());
  }
  else {
    $adjusted_total_price = $this
      ->applyAdjustments($total_price, $adjustment_types);
  }
  $rounder = \Drupal::service('commerce_price.rounder');
  $adjusted_total_price = $rounder
    ->round($adjusted_total_price);
  return $adjusted_total_price;
}