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 state (zone) information into another form.


string = afc_translate_zone_info (value, endtype)

This function was a big improvement in version 2, and can make your life a lot easier whenever your dealing with state information. Since the cart uses a zone's id number most of the time, this function makes it easier to translate a zone's id in to either the full name of the zone, or the 2 letter representation of that zone. 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 zone (id, code, 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 state is stored as an id number, but when someone changes their shipping address, the new state to ship to will be the full name of the state. Now when your coding something that might be used at checkout, you wouldn't be sure which information you actually had for that state, 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 zone, this can be an id number, 2 letter code, or full name. This function will figure out what you passed to it automatically.

endtype (string) - The type you want the zone to be returned as. Possible values are: "id", "code", and "name". Regardless of what form you pass the zone 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, zone code, or full name, this function returns nothing.

Return Values

Returns the zone 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