PDA

View Full Version : Added 'ZZ' Country Option to Zone Shipping



lamontef
05-09-2011, 07:35 PM
Hi all,

I'm fairly new to complex shipping situations (have only used simple methods that didn't require any thought before) and I've been struggling with a way to handle various shipping rate issues (International shipping) and as I got digging around I realized that the Zone shipping module could work for what I needed. In the process of doing the research that lead me to figure out how to use the feature I realized that I'd have to put every country into the Zones or not be able to have shipping rates assigned in the cart for those countries I didn't list. While looking for other options I came across the "Subtotal Shipping for Zones Module" (osCommerce Community Add-Ons (http://addons.oscommerce.com/info/6639)), which had a function to have a 'ZZ' country assigned to catch any none listed countries. So far in all my testing it seems to work perfectly for what I need.

Here's the code, if anyone sees any issues with this, please let me know:


In the section 'class methods', under 'function quote' of the 'zones.php' file, find:

if ($dest_zone == 0) {
$error = true;

and paste before:

// If dest country was not found in country zones, then look for
// 'zz' in country zones. This will leave dest_zone at 0
// if 'zz' has not been set
if ($dest_zone == 0) {
for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_ZONES_COUNTRIES_' . $i);
$country_zones = split("[,]", $countries_table);
if (in_array('ZZ', $country_zones)) {
$dest_zone = $i;
break;
}
}
}


If you have three zones of countries that you are going to list and then want one more 'catch all' entry, you can set it up for four zones with the 'ZZ' zone being the last listed.

I figured it might be beneficial to someone else...

LaMonte Forthun