Jump to content
Larry Ullman's Book Forums

Multi Currency Php For E-Commerce Site.


Recommended Posts

Hello everyone,

 

I am new to the forums but I have been reading the forums for a while now. I have a couple of Larrys books, I have really enjoyed them but now I have a little problem and I am not sure where to turn.

 

I need a little help with multi currency for a e-commerce store. I want users to choose from either GBP or USD. I have a few books on on e-commerce and php but I have not found a solution - that is why I am here!

 

If you could point me in the right direction I would be very happy!

 

Nice to meet you all,

 

Ben.

Link to comment
Share on other sites

Thanks for the nice words on the books. As for this question, the first thing you'd want to decide is whether to base the prices of things on one price, and then convert to other prices based upon a flexible conversion rate, or to set the prices in multiple currencies at once. Then it's just a matter of having a button or link or form element that the user clicks to select a currency. Store that in a cookie or session, and use that to determine what prices to display.

Link to comment
Share on other sites

Thanks for the nice words on the books. As for this question, the first thing you'd want to decide is whether to base the prices of things on one price, and then convert to other prices based upon a flexible conversion rate, or to set the prices in multiple currencies at once. Then it's just a matter of having a button or link or form element that the user clicks to select a currency. Store that in a cookie or session, and use that to determine what prices to display.

 

 

Hi Larry,

 

Thank you for getting back to me. I have choosen to format the currency in USD and have a drop down at the top for GBP. I have a thought that I could design the first page with the US flag and UK flag the user would choose.

 

In the database I would have tables for US and UK prices?

 

Not sure this will work but I will give it a go!

 

Thanks again,

 

Ben. :)

Link to comment
Share on other sites

How you design your database depends upon the issue I suggested earlier, which perhaps you didn't follow. I understand what you're saying about the user interface, but you'll need to make a decision about how you store prices: using both currencies or using one base currency and converting on the fly.

Link to comment
Share on other sites

How would you go about converting currencies on the fly? You would need to access a service somewhere that has the current value of each currency and then either it converts the currency or you have to do it in code. Do you have any information about this, Larry?

 

Thanks.

 

 

How you design your database depends upon the issue I suggested earlier, which perhaps you didn't follow. I understand what you're saying about the user interface, but you'll need to make a decision about how you store prices: using both currencies or using one base currency and converting on the fly.

Link to comment
Share on other sites

I would do something in between. It would be inefficient, and unnecessary, to look up the conversion rate from a service on the fly and use it on each page. I would be inclined to set this value in a text file or the database and then retrieve and use it. An admin script would be needed to set that value and, depending upon the site, it could be changed every X days.

Link to comment
Share on other sites

  • 2 weeks later...

Hey,

 

Sorry I haven't been around to read these answers - I have been busy (like all of us!!)

 

I think what I am going to do is set the prices in the database (as you said Larry) and have a Change Region at the top which will take the user to the correct location. I am going to read up on how to get a user location (say socks - item no 12345 - GBP) the user clicks the Change Region button and that takes them to socks - item no 12345 - USD.

 

Hope you all followed!

 

That way I have have both currencies in the database and not have to worry about it!

 

Thanks,

 

Ben.

Link to comment
Share on other sites

I notice many sites also use a visual map page that is shown when you first login, tied to a cookie so if later you come back you don't have to see the map again, that makes you select the location where you are in the world and based on that the correct version of the site is shown. This is used for language versions, prices and specific content.

  • Upvote 1
Link to comment
Share on other sites

I notice many sites also use a visual map page that is shown when you first login, tied to a cookie so if later you come back you don't have to see the map again, that makes you select the location where you are in the world and based on that the correct version of the site is shown. This is used for language versions, prices and specific content.

 

 

Hi Terry,

 

Yes I have also seen this too! This is also a great idea. I think that I need to be more better at programming to do that sort of thing!

 

Thanks again,

 

Ben.

Link to comment
Share on other sites

Some do this with js but it could also be done with an image split up into sections using a photo editor software and using a table to arrange the split sections on page, then use hyper links to pass the version to the next page.

 

Then you could do something like set variables everywhere content and prices would change and then pull from the database as you already are thinking. Instead of multiple IF statements to filter content I would setup a variable to pass in a database query. You would need to add a field in the database table for whatever version of content IF you were going to filter content otherwise you already have the prices setup as you explained above.

 

A little more work but would give flexibility to the site and you would not need multiple physical pages for each version.

 

Anyway, some more thoughts I came up with.

 

Thanks.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...