2

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();
1

1 Answer 1

2

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);
5
  • Hi amit am sourav . please can you come online at skype.
    – Sourav
    Apr 8, 2015 at 5:39
  • checkout_cart_product_add_after am using the this event
    – Sourav
    Apr 8, 2015 at 5:39
  • Fatal error: Call to a member function getCode() on a non-object in F:\xamp\htdocs\magento1.9.1\app\code\core\Mage\Directory\Model\Currency.php on line 206 this error occuring
    – Sourav
    Apr 8, 2015 at 5:59
  • check currency rate set in amdin
    – Amit Bera
    Apr 8, 2015 at 6:30
  • alredy set in currency rate option
    – Sourav
    Apr 8, 2015 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.