class Data extends AbstractHelper
{
protected $_storeManager;
protected $_currencyFactory;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
) {
$this->_storeManager = $storeManager;
$this->_currencyFactory = $currencyFactory;
parent::__construct($context);
}
function convertRate(){
$quoteAmmount = 15;
$baseCurrencyCode = $this->_storeManager->getStore()->getBaseCurrency()->getCode();
$quoteCurrency = 'CAD';
$rateToBase = $this->_currencyFactory->create()->load($quoteCurrency)->getAnyRate($baseCurrencyCode);
$totalAmount = $quoteAmmount * $rateToBase;
}
}
This is my custom code and I want to convert my CAD quote price to my store base currency which is USD. But this code returned 0.
What is the problem?