mmcb Posted January 21, 2007 Share Posted January 21, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/35054-determine-action-based-on-country/ Share on other sites More sharing options...
corillo181 Posted January 21, 2007 Share Posted January 21, 2007 if ((strtoupper($Country) == "USA") || (strtoupper($Country) == "US") || (strtoupper($Country) == "United States") ) Quote Link to comment https://forums.phpfreaks.com/topic/35054-determine-action-based-on-country/#findComment-165371 Share on other sites More sharing options...
mmcb Posted January 21, 2007 Author Share Posted January 21, 2007 So basically listing out each and every possibility using if statements :o Quote Link to comment https://forums.phpfreaks.com/topic/35054-determine-action-based-on-country/#findComment-165372 Share on other sites More sharing options...
corillo181 Posted January 21, 2007 Share Posted January 21, 2007 yeah the || is = or so is saying if is usa or us or united to execute the code.. Quote Link to comment https://forums.phpfreaks.com/topic/35054-determine-action-based-on-country/#findComment-165374 Share on other sites More sharing options...
Ninjakreborn Posted January 21, 2007 Share Posted January 21, 2007 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.00Whatever 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. Quote Link to comment https://forums.phpfreaks.com/topic/35054-determine-action-based-on-country/#findComment-165376 Share on other sites More sharing options...
corillo181 Posted January 21, 2007 Share Posted January 21, 2007 yeah i think he should give options aobut the countries.. becuase what he aske dfor it looks like he letting the costumer enter the country.. Quote Link to comment https://forums.phpfreaks.com/topic/35054-determine-action-based-on-country/#findComment-165391 Share on other sites More sharing options...
Ninjakreborn Posted January 21, 2007 Share Posted January 21, 2007 In the end, it would be too wierd leaving it to the people. People put usa, Usa USA, USa US usyou never know. Quote Link to comment https://forums.phpfreaks.com/topic/35054-determine-action-based-on-country/#findComment-165397 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.