Magento – How to handle multiple-currency and custom quote item price on Magento

event-observerquote

I have a magento store with two currency, and my items in cart have a dynamic price. I succesfully calculate my quote_item price, with an observer and setCustomPrice and setOriginalCustom price.

$quoteItem->setCustomPrice($price);
$quoteItem->setOriginalCustomPrice($price);
$quoteItem->getProduct()->setIsSuperMode(true);
$quote->save();

Best Answer

HI you need to always convert the price to base price currency because of setCustomPrice() always work on base currency.

$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); 
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();

 if($baseCurrencyCode==$currentCurrencyCode):
// convert price from current currency to base currency
$baseprice= Mage::helper('directory')->currencyConvert($price, $currentCurrencyCode, $baseCurrencyCode); 
 else:
// convert price from base currency to current currency
$baseprice= Mage::helper('directory')->currencyConvert($price, $baseCurrencyCode, $currentCurrencyCode); 
endif;

    $quoteItem->setCustomPrice($baseprice);
    $quoteItem->setOriginalCustomPrice($baseprice);