hal-11 Posted June 3, 2011 Share Posted June 3, 2011 Hi, this is my first post on the forum. I am having a bit of trouble trying to create a file with the price of a product in two different currencies. For example my $price will be calculated through a number of discounts and produce the correct price for the product in the output file, but i am now required to produce the outputted price in gbp and eur. Any help would be very much appreciated. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 I'm guessing what you want is a currency converter that is always updated with the latest rates. try something like this: http://www.dynamicguru.com/php/currency-conversion-using-php-and-google-calculator-api/ Quote Link to comment Share on other sites More sharing options...
hal-11 Posted June 3, 2011 Author Share Posted June 3, 2011 Hi, Actually the price is determined by a formulae that calculates the product price and then adds how much profit margin to be added on. the currency rate always stays the same in the formulae. So basically my output file creates all the correct prices in gbp, but in that same file I also require the output to produce a price for euro. i.e if($retailerId == 1) calculate formulae and produce price gbp. not sure how to implement it for two seperate formulaes with same retailerId but with different results(euro). Hope that helps... Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 yes, that's sort of what I was suggesting: you calcuate your gbp price with your formula, (this remains unaltered) but at the moment of displaying it, you make an api call to google, send over your price and google will return the same price in euros. then you can display both. of course this depends on what you're displaying... if it's a very long page with hundreds of prices, then api calls don't make sense because they would take too long. Quote Link to comment Share on other sites More sharing options...
hal-11 Posted June 3, 2011 Author Share Posted June 3, 2011 Yes it would actually be in batches of around 10 - 20 thousand products, so it prob wouldnt work. I will have a formulae sorted for the euro easily its just trying to implement the two at the same time. I was thinking of creating another variable say $price1 - insert euro formulae then call this the 'euro-price' header, but without much success i must admit. Brick wall meet my face Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 so basically all you need is to store the correct exchange rate somewhere you can update it from time to time, and just use that to convert the value to euros. At this moment, 1 gbp = 1.126 Euros. Just multiply gpd by the rate to get value in euros. 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.