diff --git a/Plugin/Locale/Format.php b/Plugin/Locale/Format.php index 6412dd0..0c1d59a 100644 --- a/Plugin/Locale/Format.php +++ b/Plugin/Locale/Format.php @@ -21,18 +21,9 @@ namespace Mageplaza\CurrencyFormatter\Plugin\Locale; -use Magento\Checkout\Model\Session; -use Magento\Directory\Model\Currency\DefaultLocator; -use Magento\Framework\App\RequestInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\Locale\CurrencyInterface; use Magento\Framework\Locale\Format as LocaleFormat; -use Magento\Framework\Locale\FormatInterface; -use Magento\Framework\Locale\ResolverInterface; -use Magento\Store\Model\StoreManagerInterface; -use Mageplaza\CurrencyFormatter\Helper\Data as HelperData; -use Mageplaza\CurrencyFormatter\Model\Locale\DefaultFormat; use Mageplaza\CurrencyFormatter\Plugin\AbstractFormat; /** @@ -41,40 +32,6 @@ */ class Format extends AbstractFormat { - /** - * @var Session - */ - protected $_checkoutSession; - - /** - * AbstractFormat constructor. - * - * @param StoreManagerInterface $storeManager - * @param HelperData $helperData - * @param ResolverInterface $localeResolver - * @param CurrencyInterface $localeCurrency - * @param FormatInterface $localeFormat - * @param DefaultFormat $defaultFormat - * @param DefaultLocator $currencyLocator - * @param RequestInterface $request - * @param Session $checkoutSession - */ - public function __construct( - StoreManagerInterface $storeManager, - HelperData $helperData, - ResolverInterface $localeResolver, - CurrencyInterface $localeCurrency, - FormatInterface $localeFormat, - DefaultFormat $defaultFormat, - DefaultLocator $currencyLocator, - RequestInterface $request, - Session $checkoutSession - ) { - $this->_checkoutSession = $checkoutSession; - parent::__construct($storeManager, $helperData, $localeResolver, $localeCurrency, $localeFormat, $defaultFormat, - $currencyLocator, $request); - } - /** * @param LocaleFormat $subject * @param callable $proceed @@ -112,17 +69,19 @@ public function afterGetPriceFormat(LocaleFormat $subject, $result) if (!$this->_helperData->isEnabled()) { return $result; } - $baseCurrencyCode = $this->_checkoutSession->getQuote()->getBaseCurrencyCode(); - - $code = $this->getCurrencyCode(); - if ($baseCurrencyCode) { - if (isset($result['currencyCode']) && $result['currencyCode'] === $baseCurrencyCode) { - $code = $baseCurrencyCode; - } + $baseCurrencyCode = $this->_storeManager->getStore()->getBaseCurrency()->getCode(); + $code = $this->getCurrencyCode(); + if ($baseCurrencyCode && isset($result['currencyCode']) && $result['currencyCode'] === $baseCurrencyCode) { + $code = $baseCurrencyCode; } + $config = $this->getFormatByCurrency($code); - $result['pattern'] = $this->_helperData->getLocaleShowSymbol($code, $config['show_symbol'], - $config['symbol']); + $localeShowSymbol = $this->_helperData->getLocaleShowSymbol( + $code, + $config['show_symbol'], + $config['symbol'] + ); + $result['pattern'] = $localeShowSymbol; $result['precision'] = $config['decimal_number']; $result['requiredPrecision'] = $config['decimal_number']; $result['decimalSymbol'] = $config['decimal_separator']; diff --git a/composer.json b/composer.json index fc3bdd8..3f7a086 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "mageplaza/module-core": "^1.4.4" }, "type": "magento2-module", - "version": "1.0.2", + "version": "1.0.3", "license": "proprietary", "authors": [ {