You are here

public function Order::getBalance in Commerce Core 8.2

Gets the order balance.

Calculated by subtracting the total paid price from the total price. Can be negative in case the order was overpaid.

Return value

\Drupal\commerce_price\Price|null The order balance, or NULL.

Overrides OrderInterface::getBalance

1 call to Order::getBalance()
Order::isPaid in modules/order/src/Entity/Order.php
Gets whether the order has been fully paid.

File

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

Class

Order
Defines the order entity class.

Namespace

Drupal\commerce_order\Entity

Code

public function getBalance() {
  if ($total_price = $this
    ->getTotalPrice()) {
    return $total_price
      ->subtract($this
      ->getTotalPaid());
  }
}