You are here

public function Price::add in Commerce Core 8.2

Adds the given price to the current price.

Parameters

\Drupal\commerce_price\Price $price: The price.

Return value

static The resulting price.

File

modules/price/src/Price.php, line 124

Class

Price
Provides a value object for monetary values.

Namespace

Drupal\commerce_price

Code

public function add(Price $price) : Price {
  $this
    ->assertSameCurrency($this, $price);
  $new_number = Calculator::add($this->number, $price
    ->getNumber());
  return new static($new_number, $this->currencyCode);
}