View Single Post
  #32  
Old 01-26-2007, 02:27 PM
 
wsanders wsanders is offline
 

Newbie
  
Join Date: Jun 2006
Posts: 2
 

Default Re: UPS - Setting Maximum Weight per box

Hey everyone. I don't know if this will work for every scenario but I've rewritten the code so that if you're order is over 149lbs it will send packages of 149lbs and then a final package of the 'leftover' weight. Ex -> Order is 345lbs. it will send 2 149lb packages and a 47lb package. This obviously wouldn't work if you had to ship each item in a seperate package but we ship brochures and flyers in bulk so this is perfect for us.

starting at line 323:

//Custom Code for Orders weighing over 150lbs
global $cart;
$upsmxwt = 149;
if ($UPS_weight >= $upsmxwt) {
//If order weighs more than 149lbs ship 149lb packages and the remaining lbs in a package.
$maxed_outs = floor($UPS_weight/149); //number of 149lb packages
$leftover = $UPS_weight - ($maxed_outs*149); //lbs left over

$maxed_weight = 149;

for($i=0; $i < $maxed_outs; $i++){
//send all 149lb packages
$query .=<<<EOT
<Package>
<PackagingType>
<Code>$packaging_type</Code>
</PackagingType>
<PackageWeight>
<UnitOfMeasurement>
<Code>$UPS_wunit</Code>
</UnitOfMeasurement>
<Weight>$maxed_weight</Weight>
</PackageWeight>
$dimensions_query
$pkgparams
</Package>
EOT;
}
//send the leftover weight
$query .=<<<EOT
<Package>
<PackagingType>
<Code>$packaging_type</Code>
</PackagingType>
<PackageWeight>
<UnitOfMeasurement>
<Code>$UPS_wunit</Code>
</UnitOfMeasurement>
<Weight>$leftover</Weight>
</PackageWeight>
$dimensions_query
$pkgparams
</Package>
EOT;
}
else
{
//send one package of whatever lbs if order is under 149lbs
$query .=<<<EOT
<Package>
<PackagingType>
<Code>$packaging_type</Code>
</PackagingType>
<PackageWeight>
<UnitOfMeasurement>
<Code>$UPS_wunit</Code>
</UnitOfMeasurement>
<Weight>$UPS_weight</Weight>
</PackageWeight>
$dimensions_query
$pkgparams
</Package>
EOT;
}
$query .=<<<EOT
</Shipment>
</RatingServiceSelectionRequest>
EOT;
__________________
X-Cart 4.1
Reply With Quote