Jump to content

A tweak for Shipping by Weight


Guest Christine from gecko Gully

Recommended Posts

Guest Christine from gecko Gully

In the Shipping By Weight module, you can have up to four zones within which postage is calculated. But if a customer wants shipping to a country that is not specified in one of the zones, they get an "over weight" message and cannot purchase.

I did a similar tweak for Shipping By Category, but now a client wants to use Shipping By Weight.

So what I have done is use the first one, two or three zones for specific countries, then the last one has "RW" (for "Rest of the World") in the countries field.

The customers uses this RW zone to specify the postage rates that will apply if a customer buys from a country that is not specified in one of the other zones.

Then I have changed the code in modules/shipping/By_Weight/calc.php as follows:

Look for the following code:

// build array of ISO Codes

$zones['1'] = explode(",",str_replace(" ","",strtoupper($module['zone1Countries'])));

$zones['2'] = explode(",",str_replace(" ","",strtoupper($module['zone2Countries'])));

$zones['3'] = explode(",",str_replace(" ","",strtoupper($module['zone3Countries'])));

$zones['4'] = explode(",",str_replace(" ","",strtoupper($module['zone4Countries'])));

After it, insert the following:

$defaultZone = 0;

if ($module['zone1Countries'] == "RW") { $defaultZone = 1; }

if ($module['zone2Countries'] == "RW") { $defaultZone = 2; }

if ($module['zone3Countries'] == "RW") { $defaultZone = 3; }

if ($module['zone4Countries'] == "RW") { $defaultZone = 4; }

Also, look for the following code:

// find the country

foreach ($zones as $key => $value){

foreach($zones[$key] as $no => $iso){

if($iso == $countryISO){

$shipZone = $key;

}

}

}

And after that, insert the following:

if ($shipZone == 0) {

$shipZone = $defaultZone;

}

Once again, I am using this forum as a good place to store my notes on how I am doing this, in case I have to do it again!

Christine

http://www.geckogully.com/websites

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...