Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #24 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
clean code update i18n & update composer version
  • Loading branch information
phamcuongmp authored Nov 22, 2021
2 parents 8d7a960 + ee10557 commit f7706ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 61 deletions.
67 changes: 7 additions & 60 deletions Plugin/Locale/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -41,48 +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
Expand Down Expand Up @@ -120,16 +69,14 @@ 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);
$localeShowSymbol = $this->_helperData->getLocaleShowSymbol(

$config = $this->getFormatByCurrency($code);
$localeShowSymbol = $this->_helperData->getLocaleShowSymbol(
$code,
$config['show_symbol'],
$config['symbol']
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mageplaza/module-core": "^1.4.5"
},
"type": "magento2-module",
"version": "4.0.2",
"version": "4.0.3",
"license": "proprietary",
"authors": [
{
Expand Down

0 comments on commit f7706ba

Please sign in to comment.