Hello,

I have a shopping cart and I'd like to define the shipping fees upon the continent (US-Canada / Europe / Other countries), where the items will be sent (USA = US, CA / EUR = AT, BE, BG, CZ, DK, EE * plus all the European countries / OTH = all the other countries, not listed above).

The code below works if I charge by country, but that means I have to enter the code for all the countries (not all are listed below) in the sub custom_shipping, which is a lot of lines of code.

I though to group the countries by continent, and define for each country to which continent it belongs, so instead of having $Ship_Country eq US, I could have $Ship_Continent eq EUR.

But I don't know exactly how to start… Does any one could help me and tell me how to do that?

Thanks a lot for your precious help!


sub custom_shipping
{
if ($Ship_Country eq US) {
$shipping_total = 9.00;
} elsif ($Ship_Country eq FR) {
$shipping_total = 19.00;
} else {
$shipping_total = 49.00;
}
}

sub country
{
local ($field);

%country_array =('USA', 'US',
'France', 'FR',
'Germany', 'GE',
'Ecuador','EC',
'Egypt','EG',
'El Salvador','SV',
'Equitorial Guinea','GQ',
'Eritrea','ER',
'Estonia','EE',
'Ethiopia','ET',
'Zimbabwe','ZW');

foreach $field ( sort ( keys %country_array ) )
{
if ($Bill_Country eq $country_array{$field})
{
$Bill_Country_Value = $field;
$Bill_Country_ABR = $country_array{$field};
}
if ($Ship_Country eq $country_array{$field})
{
$Ship_Country_Value = $field;
$Ship_Country_ABR = $country_array{$field};
}

if ($country_array{$field} eq $default_country && $Bill_Country eq "")
{
$bill_countries .= "<option selected value=\"$country_array{$field}\">$field</option>\n";
} else {
$bill_countries .= "<option value=\"$country_array{$field}\">$field</option>\n";
}
$ship_countries .= "<option value=\"$country_array{$field}\">$field</option>\n";
}

}