Open
Description
Hello!
In the class HistoricalPriceBox.php currencies are not respected therefore the pricebox will behave differently in stores with multiple currencies.
I would suggest to amend the class to solve this issue:
Use-Statement:
use Magento\Framework\Pricing\Helper\Data;
Class:
- add
$_priceHelper
,__construct
-method - convert the value by using
$historicalPrice = $this->_priceHelper->currency($product->getData('historical_price'), false, false);
class HistoricalPriceBox extends FinalPriceBox
{
protected $_priceHelper;
/**
* @param Context $context
* @param SaleableInterface $saleableItem
* @param PriceInterface $price
* @param RendererPool $rendererPool
* @param array $data
* @param SalableResolverInterface $salableResolver
* @param MinimalPriceCalculatorInterface $minimalPriceCalculator
* @param Data $priceHelper
*/
public function __construct(
Context $context,
SaleableInterface $saleableItem,
PriceInterface $price,
RendererPool $rendererPool,
array $data = [],
SalableResolverInterface $salableResolver = null,
MinimalPriceCalculatorInterface $minimalPriceCalculator = null,
Data $priceHelper
)
{
$this->_priceHelper = $priceHelper;
parent::__construct($context, $saleableItem, $price, $rendererPool, $data, $salableResolver, $minimalPriceCalculator);
}
public function canShowPrice(): float
{
$product = $this->getSaleableItem();
$historicalPrice = $this->_priceHelper->currency($product->getData('historical_price'), false, false);
return (int) $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue()
> (int) $historicalPrice
&& (int) $historicalPrice > 0;
}
}
Best regards!
Metadata
Metadata
Assignees
Labels
No labels