diff --git a/Block/Cart/Button.php b/Block/Cart/Button.php index 379a427..7a606fb 100644 --- a/Block/Cart/Button.php +++ b/Block/Cart/Button.php @@ -24,7 +24,6 @@ use Magento\Catalog\Model\ProductRepository; use Magento\Checkout\Model\Session; use Magento\ConfigurableProduct\Model\Product\Type\Configurable; -use Magento\Directory\Model\Currency; use Magento\Eav\Model\Entity\Collection\AbstractCollection; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; @@ -46,11 +45,6 @@ class Button extends Template */ protected $checkoutSession; - /** - * @var Currency - */ - protected $_currency; - /** * @var ProductRepository */ @@ -81,7 +75,6 @@ class Button extends Template * * @param Context $context * @param Session $checkoutSession - * @param Currency $currency * @param ProductRepository $productRepository * @param Configurable $configurable * @param PriceCurrencyInterface $priceCurrency @@ -91,14 +84,12 @@ class Button extends Template public function __construct( Context $context, Session $checkoutSession, - Currency $currency, ProductRepository $productRepository, Configurable $configurable, PriceCurrencyInterface $priceCurrency, Data $helper, array $data = [] ) { - $this->_currency = $currency; $this->checkoutSession = $checkoutSession; $this->_productRepository = $productRepository; $this->configurable = $configurable; @@ -108,16 +99,6 @@ public function __construct( parent::__construct($context, $data); } - /** - * Get currency symbol for current locale and currency code - * - * @return string - */ - public function getCurrentCurrencySymbol() - { - return $this->_currency->getCurrencySymbol(); - } - /** * @param Quote|null $quote * @@ -171,7 +152,7 @@ public function getNameConfigurable($item) */ public function formatPrice($price) { - return $this->priceCurrency->format($price, false); + return $this->helper->convertPrice($price, true, false); } /** diff --git a/Block/Cart/Items.php b/Block/Cart/Items.php index cc32e8f..fc1347a 100644 --- a/Block/Cart/Items.php +++ b/Block/Cart/Items.php @@ -32,6 +32,7 @@ use Magento\Framework\View\Element\Template\Context; use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote\Item; +use Mageplaza\ShareCart\Helper\Data; /** * Class Items @@ -59,6 +60,11 @@ class Items extends Template */ protected $configurable; + /** + * @var Data + */ + protected $helper; + /** * Items constructor. * @@ -67,6 +73,7 @@ class Items extends Template * @param Currency $currency * @param ProductRepository $productRepository * @param Configurable $configurable + * @param Data $helper * @param array $data */ public function __construct( @@ -75,24 +82,26 @@ public function __construct( Currency $currency, ProductRepository $productRepository, Configurable $configurable, + Data $helper, array $data = [] ) { $this->_currency = $currency; $this->checkoutSession = $checkoutSession; $this->_productRepository = $productRepository; $this->configurable = $configurable; + $this->helper = $helper; parent::__construct($context, $data); } /** - * Get currency symbol for current locale and currency code + * @param float $price * - * @return string + * @return float */ - public function getCurrentCurrencySymbol() + public function formatPrice($price) { - return $this->_currency->getCurrencySymbol(); + return $this->helper->convertPrice($price, true, false); } /** diff --git a/Helper/Data.php b/Helper/Data.php index ee3247c..0002a76 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -21,6 +21,10 @@ namespace Mageplaza\ShareCart\Helper; +use Magento\Framework\App\Helper\Context; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Store\Model\StoreManagerInterface; use Mageplaza\Core\Helper\AbstractData; /** @@ -32,6 +36,30 @@ class Data extends AbstractData const CONFIG_MODULE_PATH = 'sharecart'; const BUSINESS_CONFIG_PATH = 'business_information'; + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** + * Data constructor. + * + * @param Context $context + * @param ObjectManagerInterface $objectManager + * @param StoreManagerInterface $storeManager + * @param PriceCurrencyInterface $priceCurrency + */ + public function __construct( + Context $context, + ObjectManagerInterface $objectManager, + StoreManagerInterface $storeManager, + PriceCurrencyInterface $priceCurrency + ) { + $this->priceCurrency = $priceCurrency; + + parent::__construct($context, $objectManager, $storeManager); + } + /** * @return bool */ @@ -109,4 +137,24 @@ public function getWarningMessage($storeId = null) { return $this->getModuleConfig(self::BUSINESS_CONFIG_PATH . '/message', $storeId); } + + /** + * @param float $amount + * @param bool $format + * @param bool $includeContainer + * @param null $scope + * + * @return float|string + */ + public function convertPrice($amount, $format = true, $includeContainer = true, $scope = null) + { + return $format + ? $this->priceCurrency->convertAndFormat( + $amount, + $includeContainer, + PriceCurrencyInterface::DEFAULT_PRECISION, + $scope + ) + : $this->priceCurrency->convert($amount, $scope); + } } diff --git a/Helper/PrintProcess.php b/Helper/PrintProcess.php index 0cb51cf..9529d36 100644 --- a/Helper/PrintProcess.php +++ b/Helper/PrintProcess.php @@ -27,6 +27,7 @@ use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Filesystem; use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Framework\Stdlib\DateTime\DateTime; use Magento\Framework\Stdlib\DateTime\TimeZone; use Magento\Quote\Model\Quote; @@ -88,6 +89,7 @@ class PrintProcess extends Data * @param DateTime $dateTime * @param TimeZone $timezone * @param Processor $templateProcessor + * @param PriceCurrencyInterface $priceCurrency */ public function __construct( Context $context, @@ -98,7 +100,8 @@ public function __construct( Data $helper, DateTime $dateTime, TimeZone $timezone, - Processor $templateProcessor + Processor $templateProcessor, + PriceCurrencyInterface $priceCurrency ) { $this->fileSystem = $fileSystem; $this->directoryList = $directoryList; @@ -107,7 +110,7 @@ public function __construct( $this->timezone = $timezone; $this->templateProcessor = $templateProcessor; - parent::__construct($context, $objectManager, $storeManager); + parent::__construct($context, $objectManager, $storeManager, $priceCurrency); } /** diff --git a/composer.json b/composer.json index 4f9b926..87907f6 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "mageplaza/module-core": "^1.4.5", "mpdf/mpdf": "^7.1.0" }, - "version": "1.1.0", + "version": "1.1.1", "license": "proprietary", "authors": [ { diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml index 680da4b..157cc19 100644 --- a/view/frontend/layout/default.xml +++ b/view/frontend/layout/default.xml @@ -31,7 +31,7 @@ - + Mageplaza_ShareCart/js/view/minicart diff --git a/view/frontend/web/js/view/minicart.js b/view/frontend/web/js/view/minicart.js index d373c63..36dedce 100644 --- a/view/frontend/web/js/view/minicart.js +++ b/view/frontend/web/js/view/minicart.js @@ -42,6 +42,12 @@ define([ this.customer = customerData.get('cart'); }, + moveShareCart: function(){ + $(document).ready(function () { + $('.secondary.sharecart').appendTo($('.action.viewcart').parent()); + }); + }, + getQuoteId: function () { return customerData.get('cart')().quote_url; }, diff --git a/view/frontend/web/template/minicart.html b/view/frontend/web/template/minicart.html index a96a13a..c7d69e3 100644 --- a/view/frontend/web/template/minicart.html +++ b/view/frontend/web/template/minicart.html @@ -20,12 +20,10 @@ */ --> -
-
+ -