public function Price::subtract in Commerce Core 8.2
Subtracts the given price from the current price.
Parameters
\Drupal\commerce_price\Price $price: The price.
Return value
static The resulting price.
File
- modules/
price/ src/ Price.php, line 139
Class
- Price
- Provides a value object for monetary values.
Namespace
Drupal\commerce_priceCode
public function subtract(Price $price) : Price {
$this
->assertSameCurrency($this, $price);
$new_number = Calculator::subtract($this->number, $price
->getNumber());
return new static($new_number, $this->currencyCode);
}