Jump to content

Determine action based on country


mmcb

Recommended Posts

Here's the problem I'm facing.
I have an order form where people enter in there shipping details, easy enough. But what I want to happen is determine the cost of shipping based on where the user is from (ie. the country they enter).

Something like this:
if (strtoupper($Country) == "USA") {
      $Shipping = '1.00';
} else {
      $Shipping = '2.00';
}

The problem is is that people will enter varying forms of the one country (USA, US, United States, United States of America, etc). So how could I check for all the variations of country to determine what the shipping amount should be.

Cheers,
MMCB
Link to comment
Share on other sites

There is a much easier way, and this would be very fun to put together.

Take a list of all the countries (take you 20 minutes)

$countries = array(//all countries with pricing) // Example: usa=>1.00, asia=>2.00
Whatever you get the point of that part.

Now when you get ready to find out, echo out only the states, in a
<select>
foreach your countries array here to display the countries
</select>
Based on which one is picked, check the array for the price of that one, adn do what you need with it.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.