php shopping cart
free shopping cart   shopping cart software

Free Shopping Cart PHP Software


Back to Functions List
This Function Has Been Available Since:
(AFCommerce v 2.1,     Functions v 1.1)

Translates any country information into another form.


string = afc_translate_country_info (value, endtype)

This function was a big improvement in version 2, and can make your life a lot easier whenever your dealing with country information. Since the cart uses a country's id number most of the time, this function makes it easier to translate a country's id to either the full name of the country, or the 2 letter representation of that country. What's even better than that, sometimes when your adding your own feature, or modifying an existing one, you may not be sure which information you actually have for the country (id, iso_code_2, iso_code_3, or full name). This may not seem like a big deal until your actually in a situation where you can not be sure of exactly what information you have. For example, a member's country is stored as an id number, but when someone changes their shipping address, the new country to ship to will be the full name of the country. Now when your coding something that might be used at checkout, you wouldn't be sure which information you actually had for that country, so you can simply call this function with one line of code, and make sure the information is in the exact form you want it in. So you can use this function to translate an id number into its full name when necessary (which saves like 4 lines of code in that script), but you can also call it when your not sure. See the example below for the way you would use it in this situation.


value (string) - The current value of the country, this can be an id number, 2 letter iso code, 3 letter iso code, or full name. This function will figure out what you passed to it automatically.

endtype (string) - The type you want the country to be returned as. Possible values are: "id", "iso_code_2", "iso_code_3", and "name". Regardless of what form you pass the country as to this function, it will be returned as the type you pass with this parameter. If you pass information to this function that does not match a valid id number, iso_code_2, iso_code_3, or full name, this function returns nothing.

Return Values

Returns the country in the form you need the zone in, depending on which "endtype" you specify.

Open Source: No

Paul's Examples

Back to Functions List


There are currently no posts for this topic.

AFCommerce Documentation

High End Website DevelopmentCompletely Free
Dating Service
Copyright 2004 - 2006
AFCommerce Website
And Cart Builder