1 reply [Last post]
lonehorseend's picture
Offline
Joined: 12/10/2009
Juice: 23

I've been doing a Zone shipping by weight in Ubercart 2.x to back up USPS and get around the box limitations. However, you can probably set it up for other mailing systems. Here's what I've found so far:

1) Set up different classes for products with different quantities in a package. Meaning that if you have an item that contains 25 per package, it needs a class as does one with 12 per package, etc. If you are shipping items that have all the same amounts, then the standard product class will work.

2) In your USPS settings, make sure that each line item is being treated as a separate package. This helps with the packages for each item being counted correctly as well.

3) Set up a different weight condition for each zone and label the zone. I'm doing USPS, so there are 8 zones. I figured out the weight of one box and then went to USPS and looked up both the zone list for the zip code (http://postcalc.usps.gov/Zonecharts/) I was using to ship from and then the USPS parcel rates for that weight (http://pe.usps.com/text/dmm300/Notice123.htm#wp1152660).

Instead of using their 1 pound rate, I took the actual weight of the package and divided it by the number of pounds. This gave me actual per pound amount for the total pounds.

4) Once you set up the zones, there will be a link to Conditional actions for each zone. Click on one of them and, under the conditions tab, set up a group that has two custom PHP snippets joined by AND.

In the first snippet box put the code that will check the delivery zip code (without the php markers, of course). In this case, I was doing Zone 3 for my store's shipping zip code.

<?php
$num
= (int)substr($order->delivery_postal_code, 0, 3);
if (
$num == 864 || ( $num >= 889 || $num <= 891) || ( $num >= 936 || $num <= 939))
{
   return
TRUE;
}
?>

In the second snippet box put the code that will check your items and make sure there are more than 25 boxes. Again without the php markers.

<?php
$boxes
= 0;
  foreach (
$order->products as $product) {   
    if (
$product->type == "Consumer") {
   
$boxes += $product->qty /16;
    }
    else
    {
    
$boxes += $product->qty;   
    }
  }
  if (
$boxes > 25)
  {
    return
TRUE;
  }
?>
lonehorseend's picture
Offline
Joined: 12/10/2009
Juice: 23
A little more information

After through testing, I figured that you don't need 2 PHP snippets only one. Also, I made the or operator an and operator for the range.

So here's the new snippet:

<?php
$boxes
= 0;
  foreach (
$order->products as $product) {  
    if (
$product->type == "Consumer") {
   
$boxes += $product->qty /16;
    }
    else
    {
    
$boxes += $product->qty;  
    }
  }
  if (
$boxes > 25)
  {
   
$num = (int)substr($order->delivery_postal_code, 0, 3);
    if (
$num == 864 || ( $num >= 889 && $num <= 891) || ($num >= 936 && $num <= 939))
{
   return
TRUE;
}
  }
?>

All other steps remain the same