priceCurrency = $priceCurrency; parent::__construct($context, $data); } /** * @param AmountRenderInterface $amountRender * @param array $arguments * @return string */ public function render(AmountRenderInterface $amountRender, array $arguments = []) { $this->amountRender = $amountRender; $origArguments = $this->getData(); $this->setData(array_replace($origArguments, $arguments)); $html = $this->apply(); // restore original block arguments $this->setData($origArguments); return $html; } /** * @return AmountRenderInterface */ public function getAmountRender() { return $this->amountRender; } /** * @param string $priceCode * @return PriceInterface */ public function getPriceType($priceCode) { return $this->getSaleableItem()->getPriceInfo()->getPrice($priceCode); } /** * @return \Magento\Framework\Pricing\Price\PriceInterface */ public function getPrice() { return $this->amountRender->getPrice(); } /** * @return SaleableInterface */ public function getSaleableItem() { return $this->amountRender->getSaleableItem(); } /** * Format price value * * @param float $amount * @param bool $includeContainer * @param int $precision * @return string */ public function formatCurrency( $amount, $includeContainer = true, $precision = PriceCurrencyInterface::DEFAULT_PRECISION ) { return $this->priceCurrency->format($amount, $includeContainer, $precision); } /** * Convert and format price value * * @param float $amount * @param bool $includeContainer * @param int $precision * @return string */ public function convertAndFormatCurrency( $amount, $includeContainer = true, $precision = PriceCurrencyInterface::DEFAULT_PRECISION ) { return $this->priceCurrency->convertAndFormat($amount, $includeContainer, $precision); } /** * @return \Magento\Framework\Pricing\Adjustment\AdjustmentInterface */ public function getAdjustment() { return $this->getSaleableItem()->getPriceInfo()->getAdjustment($this->getAdjustmentCode()); } /** * @return string */ abstract protected function apply(); }