You are here

public function Price::convert in Commerce Core 8.2

Converts the current price to the given currency.

Parameters

string $currency_code: The currency code.

string $rate: A currency rate corresponding to the currency code.

Return value

static The resulting price.

File

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

Class

Price
Provides a value object for monetary values.

Namespace

Drupal\commerce_price

Code

public function convert($currency_code, $rate = '1') : Price {
  $new_number = Calculator::multiply($this->number, $rate);
  return new static($new_number, $currency_code);
}