hozzt Posted February 15, 2010 Share Posted February 15, 2010 hi, we are in turkey and we sell our products in US dollars. but our costumers want to see the exact turkish lira rate and they want to know how much turkish money they are going to pay. we want to show both $ and TL and/or the conversion rate of the exact time. is it possible? thank you. 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted February 15, 2010 Share Posted February 15, 2010 (edited) The following script gets the current USD and TRY conversion rate from the European Central Bank website. {php} $XMLContent = file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"); $amount = 1.00; foreach($XMLContent as $line) { if(ereg("currency='USD'", $line, $currencyCode)) ereg("rate='([[:graph:]]+)'", $line, $usd); if(ereg("currency='TRY'", $line, $currencyCode)) ereg("rate='([[:graph:]]+)'", $line, $try); } echo $amount." USD = ".round($amount / $usd[1] * $try[1], 2)." TRY"; {/php} The feed is updates once a day. Recommended is to cache the values so it doesn't load every time someone loads the cart. Based on this you can try to modify it so it will convert the cart total. Edited February 15, 2010 by m00 0 Quote Link to comment Share on other sites More sharing options...
hozzt Posted February 15, 2010 Author Share Posted February 15, 2010 thank you.. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.