You are here

public function Order::getTotalPaid in Commerce Core 8.2

Gets the total paid price.

Return value

\Drupal\commerce_price\Price|null The total paid price, or NULL.

Overrides OrderInterface::getTotalPaid

1 call to Order::getTotalPaid()
Order::getBalance in modules/order/src/Entity/Order.php
Gets the order balance.

File

modules/order/src/Entity/Order.php, line 476

Class

Order
Defines the order entity class.

Namespace

Drupal\commerce_order\Entity

Code

public function getTotalPaid() {
  if (!$this
    ->get('total_paid')
    ->isEmpty()) {
    return $this
      ->get('total_paid')
      ->first()
      ->toPrice();
  }
  elseif ($total_price = $this
    ->getTotalPrice()) {

    // Provide a default without storing it, to avoid having to update
    // the field if the order currency changes before the order is placed.
    return new Price('0', $total_price
      ->getCurrencyCode());
  }
}