Hello, i am trying to write a bit of script that will add a delivery cost based on the country code which is provided from a form. Everything works, except my last else statement. As an example, i am trying to make the delivery 1.15 if the country code is GB, 2.15 for EU countries that have been listed and 3.15 for any other code that has not been mentioned. When i select the UK from the dropdown list, the delivery appears as it should and when i go back and change it to a EU country the delivery updates correctly. However, when i select a non-EU country, the output remains at 2.15, can anyone lend a hand?

if ($strDeliveryCountry == GB){
else {
 if ($strdeliveryCountry == AI||AD||AM||AT||BY||BE|| etc etc){
 } else $delivery=3.15;
5 Years
Discussion Span
Last Post by jpknoob

Why not try something like:

if($country == 'GB')
    $delivery = 1.15;
elseif(in_array($county, array('AI', 'AD', 'AM', 'AT', 'BY', 'BE'))
    $delivery = 2.15;
    $delivery = 3.15;

All, variable names are case sensitive, and strings should be wrapped in single quotes (or double depending on usage). This may help explain the odd behaviour you've encountered.


Edited by blocblue: n/a


Tried your code and it worked perfectly, you just forgot to add another closed quote after the else if ;)

Many Thanks!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.