How to handle the price with multiple currencies and the custom quote price on Magento?

I have a magento store with two currencies and my items in the cart have a dynamic price. I am successfully calculating my quote_item price with observer rating and setCustomPrice and setOriginalCustom

 $quote_item->setCustomPrice($price);
 $quote_item->setOriginalCustomPrice($price);

And my observer:

<sales_quote_add_item>

But I have a problem, when I change the currency of my store, the subtotal is not updated. How to handle the price of several currencies and the user price of quotes?

+5
source share
3 answers

. → setOriginalCustomPrice , , , , , , .

. :

<models>
        <catalog>
            <rewrite>
                <product>PixieMedia_CustomPrice_Model_Product</product>
            </rewrite>
        </catalog>
</models>

, → getFinalPrice - , .

Product.php /app/code/local/Namespace/Module/Model/Product.php

class PixieMedia_CustomPrice_Model_Product extends Mage_Catalog_Model_Product {

public function getFinalPrice($qty=null)
// REWRITTEN FUNCTION TO RETURN THE SPECIAL PRICE AND ENSURE CURRENCY CONVERSION
{
    $qBreak = false;
    $customPrice = Mage::Helper('pixiemedia_customprice')->getCustomerPrice($this);

    if($qty) { 
        $qBreak = $this->getQtyBreakPrice($this->getSku(),$qty,$customPrice[0]); 
        }

    if($qBreak) { return $qBreak; } else { return $customPrice[0]; }

}

}

, , - , Magento . , , qty.

, . , .

, -. :)

+1

observer

< sales_quote_item_set_product >

$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
if($currentCurrencyCode!=$baseCurrencyCode)
    $price= Mage::helper('directory')->currencyConvert($baseprice, $baseCurrencyCode, $currentCurrencyCode); 
else
    $price = $baseprice;

$item->setPrice($baseprice);
$item->setRowTotal($item->getQty() * $price);
0

You will probably miss the call:

$quote->collectTotals()->save();
-3
source

All Articles