![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-configurable-product/Pricing/Render/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\ConfigurableProduct\Pricing\Render; use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface; use Magento\Catalog\Pricing\Price\FinalPrice; use Magento\Catalog\Pricing\Price\MinimalPriceCalculatorInterface; use Magento\Catalog\Pricing\Price\RegularPrice; use Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface; use Magento\Framework\Pricing\Price\PriceInterface; use Magento\Framework\Pricing\Render\RendererPool; use Magento\Framework\Pricing\SaleableInterface; use Magento\Framework\View\Element\Template\Context; /** * Class for final_price box rendering */ class FinalPriceBox extends \Magento\Catalog\Pricing\Render\FinalPriceBox { /** * @var ConfigurableOptionsProviderInterface */ private $configurableOptionsProvider; /** * @param Context $context * @param SaleableInterface $saleableItem * @param PriceInterface $price * @param RendererPool $rendererPool * @param SalableResolverInterface $salableResolver * @param MinimalPriceCalculatorInterface $minimalPriceCalculator * @param ConfigurableOptionsProviderInterface $configurableOptionsProvider * @param array $data */ public function __construct( Context $context, SaleableInterface $saleableItem, PriceInterface $price, RendererPool $rendererPool, SalableResolverInterface $salableResolver, MinimalPriceCalculatorInterface $minimalPriceCalculator, ConfigurableOptionsProviderInterface $configurableOptionsProvider, array $data = [] ) { parent::__construct( $context, $saleableItem, $price, $rendererPool, $data, $salableResolver, $minimalPriceCalculator ); $this->configurableOptionsProvider = $configurableOptionsProvider; } /** * Define if the special price should be shown * * @return bool */ public function hasSpecialPrice() { $product = $this->getSaleableItem(); foreach ($this->configurableOptionsProvider->getProducts($product) as $subProduct) { $regularPrice = $subProduct->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getValue(); $finalPrice = $subProduct->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue(); if ($finalPrice < $regularPrice) { return true; } } return false; } }