Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

UPS - Setting Maximum Weight per box

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #31  
Old 12-21-2006, 12:47 PM
 
Audiolines Audiolines is offline
 

Senior Member
  
Join Date: Mar 2006
Posts: 102
 

Default Re: UPS - Setting Maximum Weight per box

nick, worked great in 4.0.17
__________________
version 4.0.17
Reply With Quote
  #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
  #33  
Old 01-26-2007, 02:29 PM
 
Kishy Kishy is offline
 

Advanced Member
  
Join Date: Jul 2006
Posts: 39
 

Default Re: UPS Over 150 pounds

Quote:
Originally Posted by satcruiser
I recommend the last solution where items are rated as individual items if the total weight exceeds 150 pounds.

For those of us who are using x-cart Gold version 4.1.2 the $cart array definition where you need to add the "weight" definition is in file ../include/process_cart.php

$cart["products"][]=array("cartid"=>$cartid, "productid"=>$productid,"amount"=>$amount, "options"=>$product_options, "weight"=>$added_product["weight"], "free_price"=>@price_format(@$free_price),"distrib ution"=>$product_distribution);

It works GREAT. Thanks
I am trying to use this mod to solve the same UPS shipping error and I can't find the file called process_cart.php. I have version 4.1.2.
__________________
Kishy
xcart@generalgraphic.com
X-Cart Version 4.1.2 [Linux]
Reply With Quote
  #34  
Old 01-26-2007, 03:54 PM
 
wsanders wsanders is offline
 

Newbie
  
Join Date: Jun 2006
Posts: 2
 

Default Re: UPS Over 150 pounds

Quote:
Originally Posted by Kishy
I am trying to use this mod to solve the same UPS shipping error and I can't find the file called process_cart.php. I have version 4.1.2.

In 4.1 the file is called cart_process.php and it is in the folder /include/

The code looks different too ...
bout halfway through the file you need to replace
$cart["products"][] = array(
"cartid" => $cartid,
"productid" => $productid,
"amount" => $amount,
"options" => $product_options,
"free_price" => @price_format(@$free_price),
"distribution" => $added_product["distribution"],
"variantid" => $variantid);

with

$cart["products"][] = array(
"cartid" => $cartid,
"productid" => $productid,
"amount" => $amount,
"options" => $product_options,
"weight"=>$added_product["weight"],
"free_price" => @price_format(@$free_price),
"distribution" => $added_product["distribution"],
"variantid" => $variantid);
__________________
X-Cart 4.1
Reply With Quote
  #35  
Old 02-08-2007, 09:46 AM
 
Kishy Kishy is offline
 

Advanced Member
  
Join Date: Jul 2006
Posts: 39
 

Default Re: UPS - Setting Maximum Weight per box

Sweet! It worked. However if I have a single product over 150lbs I get the error code. Any fix for that?
__________________
Kishy
xcart@generalgraphic.com
X-Cart Version 4.1.2 [Linux]
Reply With Quote
  #36  
Old 06-11-2007, 08:00 PM
 
manolodf manolodf is offline
 

Advanced Member
  
Join Date: Jun 2003
Posts: 50
 

Default Re: UPS - Setting Maximum Weight per box

Cherie, this was a great mod, but i realized there was a bug, if you attempt to use an Alaska Zip code 99669 for example, you will see that it will return 2 prices for some reason, and when the customer is viewing it normally returns the first one only. This could have something to do with the zones etc.

Thanks
Shipping Rates
FedEx Ground ($ 0.00)

FedEx Ground ($ 343.24)



Quote:
Originally Posted by cherie
I ran into this same problem with FedEx. I'm posting this here in case it helps someone with UPS and because I didn't find any other posts related to this for FedEx.

A store owner has some products that individually fit into 53 lb packages. If someone orders 2 of them, the total weight is 106 lbs. This exceeds the FedEx Home Deliver limit of 70 lbs. If you haven't set Weight Limit for Home Delivery then the cart will only give you the rate up to 70 lbs (at least it appears that way). If you set the Weight Limit for Home Deliver to 70 lbs (like you probably should) then FedEx Home Deliver no longer appears as a shipping method for the order since the total weight is 106 lbs.

We changed shipping/mod_FEDEX.php to break the shipping into 53 lb (max) chunks then add up the chunks, giving a total shipping amount. Here are the changes that accomplished this.

In function get_rate, find:
PHP Code:
$row func_query_first("SELECT * FROM $sql_tbl[fedex_rates] WHERE r_meth_id = '".$method_id."' AND r_zone = '".$zone."' AND r_weight <= ".$weight." ORDER BY r_rate DESC LIMIT 1"); 
replace with:
PHP Code:
error_log("",0);
    
error_log("FedEx $method ($method_id), zone $zone",0);
    
$maxwt 53;        # max lbs per box
    
$rate 0;          # default rate value
    
$weight_orig $weight# remember original weight
    
$pkgcount 0;      # number of packages
    
while ($weight 0) {
        
$pkgcount++;
        if (
$weight $maxwt) {
            
$weight_rem $weight $maxwt;
            
$weight $maxwt;
            
$row func_query_first("SELECT * FROM $sql_tbl[fedex_rates] WHERE r_meth_id = '".$method_id."' AND r_zone = '".$zone."' AND r_weight <= ".$weight." ORDER BY r_rate DESC LIMIT 1");
            if (
$row) {
                
$this_rate $row[r_rate];
                
error_log("$weight lbs = $this_rate",0);
                
$rate += $this_rate;
            }
            
$weight $weight_rem;
        } else {
            
$row func_query_first("SELECT * FROM $sql_tbl[fedex_rates] WHERE r_meth_id = '".$method_id."' AND r_zone = '".$zone."' AND r_weight <= ".$weight." ORDER BY r_rate DESC LIMIT 1");
            if (
$row) {
                
$this_rate $row[r_rate];
                
error_log("$weight lbs = $this_rate",0);
                
$rate += $this_rate;
            }
            
$weight 0;
        }
     }
    
$weight $weight_orig
find:
PHP Code:
if ($row) {
        
# exact weight match
        
return $row["r_rate"];
    } 
replace with:
PHP Code:
if ($rate 0) {
        
error_log("RATE $rate",0);
        
# exact weight match
        
return array($rate$pkgcount);
    } 
Use the package count ($pkgcount) to multiply the Home Delivery surchage. In function AddMethods find:
PHP Code:
$rate get_rate($weight$method['name'], $zone); 
replace with:
PHP Code:
list($rate,$pkgcount) = get_rate($weight$method['name'], $zone); 
Also, find:
PHP Code:
$rate $rate $fuel_addon $method['addon']; 
replace with:
PHP Code:
$addon $method[addon] * $pkgcount;
$rate $rate $fuel_addon $addon;
error_log("packages $pkgcount, fuel $fuel_addon, method $addon = $rate",0); 
As you can see, I like to log stuff so I can see what the cart is doing. Here is a sample of the log after the above changes:
Code:
[25-Sep-2005 15:43:05] FedEx Ground (43), zone 2 [25-Sep-2005 15:43:05] 53 lbs = 10.08 [25-Sep-2005 15:43:05] 53 lbs = 10.08 [25-Sep-2005 15:43:05] RATE 20.16 [25-Sep-2005 15:43:05] packages 2, fuel 0.6, method 0 = 20.76 [25-Sep-2005 15:43:05] [25-Sep-2005 15:43:05] FedEx Home Delivery (44), zone 2 [25-Sep-2005 15:43:05] 53 lbs = 10.08 [25-Sep-2005 15:43:05] 53 lbs = 10.08 [25-Sep-2005 15:43:05] RATE 20.16 [25-Sep-2005 15:43:05] packages 2, fuel 0.6, method 2.9 = 26.56
The modifications above don't mess with how rates are obtained. It just breaks the total weight into smaller chunks. The store owner doesn't ship 106 lb packages, but 53 lb packages, so this works for them. Your requirements may be different.

Additionally, we found that the rates were not correct in some instances. This was tracked down to function get_zone. It appears that the destination zip code may be in multiple zones. The closer zone is probably the one you should be using so we found:
PHP Code:
$row func_query_first("SELECT * FROM $sql_tbl[fedex_zips] WHERE (zip_first<='$zp3') AND (IF(zip_last='', '$zp3'=zip_last, '$zp3'<=zip_last)) AND zip_meth='$methid'"); 
and changed to:
PHP Code:
$row func_query_first("SELECT * FROM $sql_tbl[fedex_zips] WHERE (zip_first<='$zp3') AND (IF(zip_last='', '$zp3'=zip_last, '$zp3'<=zip_last)) AND zip_meth='$methid' order by zip_zone asc"); 
This change says I want the lowest number zone if there are more than one. This coincided with fedex.com's rate finder. fedex.com was saying the zone was 2, in my test, while the cart was giving me the higher rates in zone 6. The database was returning two rows (zone 2 and zone 6) but zone 6 was coming up first. Only the first one to come back is what the original code uses. This change fixes that.

This was done with 4.0.11 but I could find nothing in the changelog nor code changes to this section that would indicate that it is any different up to 4.0.16.

This should be tested and someone should please post a correction if any of this information is inaccurate. I am not a shipping expert.

update - I found that FedEx Home Delivery surcharge is applied per package. I added a package counter ($pkgcounter) to the get_rate function, get_rate now returns the rate and number of packages, and AddMethods now uses the returned package count to multiply the FedEx Home Delivery.
__________________
X-Cart Gold v4.1.9
Reply With Quote
  #37  
Old 07-09-2007, 11:10 AM
 
nevets1219 nevets1219 is offline
 

eXpert
  
Join Date: Jun 2006
Posts: 351
 

Default Re: UPS - Setting Maximum Weight per box

I was wondering if the mod, mentioned here by cherie works with 4.1.8?

Are there any other problems other than the one mentioned in the above posts about?

We have a few packages that requires its own package (and cannot be packaged with other products) and we think this could work to help seperate the items. If anyone knows of another solution, pleas let me know!

Thanks!
__________________
4.1.8
Reply With Quote
  #38  
Old 07-10-2007, 07:44 AM
 
dave70 dave70 is offline
 

Newbie
  
Join Date: Mar 2007
Posts: 6
 

Default Re: UPS - Setting Maximum Weight per box

I've read through the numerous posts about UPS weight limitations, no help from X-Cart devs, update in version 5, costs for custom modifications, etc, so instead of wasting time worrying about the situation, I decided I would try to take anything that was available and make it work for what I needed it to do.

I took the code from nick1628 and modified it slightly to fit into the templates for version 4.1.7. The code was completely different from the start so I had to do some trial and error. Everything looks like it is working properly, and shipping is now calculated based upon each individual product weight, then added together.

cart.php ----- original starting at line 198
Code:
# # Add product to the cart # $add_product = array(); $add_product["productid"] = abs(intval($productid)); $add_product["amount"] = abs(intval($amount)); $add_product["product_options"] = $product_options; $add_product["price"] = abs(doubleval($price));

cart.php ----- new starting at same point
Code:
# # Add product to the cart # $add_product = array(); $add_product["productid"] = abs(intval($productid)); $add_product["amount"] = abs(intval($amount)); $add_product["product_options"] = $product_options; $add_product["weight"] = $weight; $add_product["price"] = abs(doubleval($price));


shipping/mod_UPS.php ----- original starting at line 349
Code:
</ShipTo> <Package> <PackagingType> <Code>$packaging_type</Code> </PackagingType> <PackageWeight> <UnitOfMeasurement> <Code>$UPS_wunit</Code> </UnitOfMeasurement> <Weight>$UPS_weight</Weight> </PackageWeight> $dimensions_query $pkgparams </Package> $shipment_options_xml $handling_xml $negotiated_rates_xml </Shipment> </RatingServiceSelectionRequest> EOT;

shipping/mod_UPS.php ----- new starting at same point
Code:
</ShipTo> EOT; global $cart; foreach($cart['products'] as $prodKey => $prodArray) { for($quantity=0; $quantity<$prodArray['amount'];$quantity++) { $prodWeight = $prodArray['weight']; $query .=<<<EOT <Package> <PackagingType> <Code>$packaging_type</Code> </PackagingType> <PackageWeight> <UnitofMeasurement> <Code>$UPS_wunit</Code> </UnitofMeasurement> <Weight>$prodWeight</Weight> </PackageWeight> $dimensions_query $pkgparams </Package> $shipment_options_xml $handling_xml $negotiated_rates_xml EOT; } } $query .=<<<EOT </Shipment> </RatingServiceSelectionRequest> EOT;

I might try to tweak this some more because my client actually ships in packages of 2. Currently the shipping is charging slightly more than it should, so we'll see what happens.
__________________
XCart - Version 4.1.6 & 4.1.7
Reply With Quote

The following user thanks dave70 for this useful post:
supernovia (09-30-2009)
  #39  
Old 08-02-2007, 07:29 AM
  rogue's Avatar 
rogue rogue is offline
 

X-Adept
  
Join Date: Apr 2007
Location: Loveland, Ohio
Posts: 770
 

Default Re: UPS - Setting Maximum Weight per box

Can you verify that the final mod tells UPS that you are shipping one package per product ordered?
__________________
Richard Williams
Rogue Wave Limited

Initial Inventory Imports
Daily Inventory Updates
Daily Inventory Reports
Drop Ship Support
Order Export to Shipper/Supplier
Shopping Feeds That Work
Programming for X-Cart

richard@roguewavelimited.com
http://www.roguewavelimited.com
Reply With Quote
  #40  
Old 12-04-2007, 12:18 PM
  Qdox's Avatar 
Qdox Qdox is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 57
 

Default Re: UPS - Setting Maximum Weight per box

Hi, for my structured I liked the one from "wsanders", althought it limits me to 2 packages of 300 but that work for me for now. I also tried the previous mod, but the calculations were not right, and this one give me a very close estimate of what I get on the ups web site while doing a manual shipment. This one works for 4.1.8.

Quote:


</ShipTo>
EOT;
#Custom Code for Orders weighing over 150lbs. change this code of mod_UPS.php after line 349.
global $cart;
$maxed_weight = 149;
if ($UPS_weight >= $maxed_weight) {
#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
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>
$shipment_options_xml
$handling_xml
$negotiated_rates_xml
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>
$shipment_options_xml
$handling_xml
$negotiated_rates_xml
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>
$shipment_options_xml
$handling_xml
$negotiated_rates_xml
EOT;
}
$query .=<<<EOT
</Shipment>
</RatingServiceSelectionRequest>
EOT;

__________________
QdoxGroup
X-Cart version 4.1.8 Pro
HandsOnWebHosting.
Web server Apache/2.0.52 (Red Hat)
http://www.justinthenet.com/
Reply With Quote

The following user thanks Qdox for this useful post:
ryedlin (02-11-2010)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:36 AM.

   

 
X-Cart forums © 2001-2020