andries Posted July 11, 2010 Share Posted July 11, 2010 Hi to allI am really not understanding how the currencies and the conversion of prices are working.From which file/other function is the function "convertPrice", from tools.php called? I don't find it anywhere...Kind regardsAndries Link to comment Share on other sites More sharing options...
razaro Posted July 11, 2010 Share Posted July 11, 2010 In classes/Tools.php there is function /** * Return price converted * * @param float $price Product price * @param object $currency Current currency object */ static public function convertPrice($price, $currency = NULL) { if ($currency === NULL) $currency = Currency::getCurrent(); $c_id = (is_array($currency) ? $currency['id_currency'] : $currency->id); $c_rate = (is_array($currency) ? $currency['conversion_rate'] : $currency->conversion_rate); if ($c_id != intval(Configuration::get('PS_CURRENCY_DEFAULT'))) $price *= $c_rate; return $price; } Also in classes/Product.php there is similar functions but that are calling displayPrices() from tools.php Link to comment Share on other sites More sharing options...
andries Posted July 11, 2010 Author Share Posted July 11, 2010 hi thanks for the replyIt is indeed this function where I am talking about. I just need to know where it is called from.This is the issue I have: when I click on another currency, only the display of the sign changes, and the price is still displayed in the old currency. However when I proceed to the order, the prices are displayed (and converted) correctly at that moment.I have been looking around, but as you mention in product.php, the function displayPrice is called, but the function displayPrice don't call for the function convertPrice. I tried to add this call, and prices were displayed correctly, but when proceeding to the order, it guess it is called again, and the conversion takes place twice.If i echo next to the price the conversion rate, or a var_dump of the $currency object, everything is really as it has to be... I have the feeling that somehow this function convertPrice is no longer called... So I would like to check my code, and see if I didn't remove it anywhere. But I was hoping that someone from PrestaShop or another developer could point me out where the function converPrice should be called... Link to comment Share on other sites More sharing options...
razaro Posted July 11, 2010 Share Posted July 11, 2010 I am not sure but i think it is going like this.When you click on some currency JavaScript function is called and it make submit.Page reloads with new currency id which is forwarded to converPrice function.For example call is made in product-list.tpl <span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} My guess that maybe there is some JavaScript error that stops this process. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now