php - How to handle multiple-currency and custom quote item price on Magento? -
i have magento store 2 currency, , items in cart have dynamic price. succesfully calculate quote_item price, observer , setcustomprice , setoriginalcustom price
$quote_item->setcustomprice($price); $quote_item->setoriginalcustomprice($price);
and observer:
<sales_quote_add_item>
but have problem, when change currency of store, subtotal not update. how handle multiple-currency , custom quote item price ?
i've had same issue on last week. using ->setoriginalcustomprice method fine single currency site, currency switching, rigidness means need update cart items , list price everytime currency switched, inefficient in opinion.
i came more elegant solution. create module , within model section of config add this;
<models> <catalog> <rewrite> <product>pixiemedia_customprice_model_product</product> </rewrite> </catalog> </models>
counter intuitively, main ->getfinalprice function in product model , not price model.
now create new product.php model in /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 return special price , 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]; } } }
on particular project working on, client using multiple price lists customer specific pricing, scope of make magento horrendously slow index pricing. we've loaded data custom table , perform lookup return customer's correct price or qty break.
it's dead easy hook own logic in , return ever price wish. supports currency conversion, no need fiddle around re-converting prices.
hope helps out. enjoy :)
Comments
Post a Comment