| Current Path : /var/www/magento.test.indacotrentino.com/www/app/code/Webkul/BuyButton/Plugin/ |
| Current File : /var/www/magento.test.indacotrentino.com/www/app/code/Webkul/BuyButton/Plugin/GuestCartItem.php |
<?php
/**
* Webkul Software
*
* @category Webkul
* @package Webkul_BuyButton
* @author Webkul
* @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
* @license https://store.webkul.com/license.html
*/
namespace Webkul\BuyButton\Plugin;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Catalog\Api\Data\ProductRender\FormattedPriceInfoInterfaceFactory;
class GuestCartItem
{
public function __construct(
\Magento\Framework\Webapi\Rest\Request $request,
\Magento\Store\Model\StoreManagerInterface $storeManager,
FormattedPriceInfoInterfaceFactory $formattedPriceInfoFactory,
PriceCurrencyInterface $priceCurrency,
\Magento\Framework\Session\SessionManagerInterface $coreSession
) {
$this->formattedPriceInfoFactory = $formattedPriceInfoFactory;
$this->request = $request;
$this->storeManager = $storeManager;
$this->_coreSession = $coreSession;
$this->priceCurrency = $priceCurrency;
}
public function afterGetList(
\Magento\Quote\Model\GuestCart\GuestCartItemRepository $subject,
$result
) {
$currRate = $this->storeManager->getStore()->getCurrentCurrencyRate();
$storeId = $this->storeManager->getStore()->getId();
$this->_coreSession->start();
$currencyCode = $this->_coreSession->getCurrencyCode();
/** @var FormattedPriceInfo $formattedPriceInfo */
$formattedPriceInfo = $this->formattedPriceInfoFactory->create();
foreach ($result as $item) {
$value = $this->priceCurrency->convert($item->getPrice(), $storeId, $currencyCode);
$item->setPrice($value);
}
return $result;
}
}