product = $saleableItem; $this->quantity = $quantity; $this->calculator = $calculator; $this->priceCurrency = $priceCurrency; $this->priceInfo = $saleableItem->getPriceInfo(); } /** * Get price value in display currency * * @return float|bool */ abstract public function getValue(); /** * Get Price Amount object * * @return AmountInterface */ public function getAmount() { if (!isset($this->amount[$this->getValue()])) { $this->amount[$this->getValue()] = $this->calculator->getAmount($this->getValue(), $this->getProduct()); } return $this->amount[$this->getValue()]; } /** * @param float $amount * @param null|bool|string|array $exclude * @param null|array $context * @return AmountInterface|bool|float */ public function getCustomAmount($amount = null, $exclude = null, $context = []) { if (null !== $amount) { $amount = $this->priceCurrency->convertAndRound($amount); } else { $amount = $this->getValue(); } return $this->calculator->getAmount($amount, $this->getProduct(), $exclude, $context); } /** * Get price type code * * @return string */ public function getPriceCode() { return static::PRICE_CODE; } /** * @return SaleableInterface */ public function getProduct() { return $this->product; } /** * @return float */ public function getQuantity() { return $this->quantity; } }