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
  #11  
Old 03-23-2005, 05:18 PM
 
sabrina sabrina is offline
 

Advanced Member
  
Join Date: Feb 2003
Location: Indianapolis, IN., USA
Posts: 53
 

Default

To anyone having this problem,

I have installed the mods that nick1628 posted on Tue Mar 01, 2005 5:20 pm and that has taken care of the problem.

I can now ship via UPS, mutiple items in one order even if the total weight is greater than 150 lbs..

Thanks Nick for the code and the quick response when I had a problem installing it (really my lack of knowledge that caused the problem).

X-Cart wanted to charge me to fix their module. Is that how they normally treat customers that find problems in their programs?

Leon P.

Can you share it with "anyone"?
__________________
X-CART GOLD: 4.0.14

Operating system Linux
Apache version 1.3.33 (Unix)
PERL version 5.8.1
PHP version 4.3.10
MySQL version 4.0.22-standard
Reply With Quote
  #12  
Old 03-23-2005, 07:06 PM
 
nick1628 nick1628 is offline
 

Member
  
Join Date: Nov 2004
Posts: 15
 

Default

sure...the problems arise as follows:

if there are spaces after: $query=<<<EOT remove them

and then make sure that the lines that say:

EOT;

make sure it is all the way to the left of the page and there are no spaces afterwards...if you have any problems just send me a message and i can help you out

- nick
__________________
xcart pro v3.5.12 [win]
Reply With Quote
  #13  
Old 03-24-2005, 10:48 PM
 
PremiumPonyParts PremiumPonyParts is offline
 

Senior Member
  
Join Date: Dec 2004
Posts: 114
 

Default

I was able to get this to work on 4.0.7 by changing the following

Code:
$prodWeight = $prodArray['weight']; $query .=<<<EOT <Package> <PackagingType> <Code>$packaging_type</Code> </PackagingType> <PackageWeight> <UnitOfMeasurement> <Code>$UPS_wunit</Code> </UnitOfMeasurement> <Weight>$prodWeight</Weight> </PackageWeight>
TO
Code:
$UPS_weight = $prodArray['weight']; $query .=<<<EOT <Package> <PackagingType> <Code>$packaging_type</Code> </PackagingType> <PackageWeight> <UnitOfMeasurement> <Code>$UPS_wunit</Code> </UnitOfMeasurement> <Weight>$UPS_weight</Weight> </PackageWeight>

But I'd like to know if it splits them up only if bigger than 150, or no matter what
__________________
Version 4.0.8
Reply With Quote
  #14  
Old 03-24-2005, 11:24 PM
 
PremiumPonyParts PremiumPonyParts is offline
 

Senior Member
  
Join Date: Dec 2004
Posts: 114
 

Default

IMO, this mod is greate. But shouldnt be used on any live site until it calculates if it does indeed need to use the over 150 weight limit mod. Otherwise, it can bump up your shipping cost 100%. I tested an order that i shipped. It shipped at $14 for a 2 lb package (2 lbs items in the same box). This mod, made it two 1lb packages, so it was like $26 to ship. Thats outragoues. That was for UPS 3 day. For regular ground it went up about $5. For me, my shipping prices are already high because of my suppliers dropship and minimum order charges, so I need to keep shipping down.

If you dont mind the extra bumps in shipping, use it. Works great and is the only alternative out there.


Here is a soultion.
Code:
//<? //only in here to make code look nicer in php editor..doesn't affect anything global $cart; $upsmxwt = "150"; if ($UPS_weight >= $upsmxwt) { foreach($cart['products'] as $prodKey => $prodArray) { for( $quantity=0; $quantity<$prodArray['amount'];$quantity++) { $UPS_weight = $prodArray['weight']; $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; } } } else { $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>

It works good for unders under 150 pounds. But once over, it does it by individual boxes once again. Hope it helps someone. Thanks to Nick for the beginning code.
__________________
Version 4.0.8
Reply With Quote
  #15  
Old 03-25-2005, 09:50 AM
 
nick1628 nick1628 is offline
 

Member
  
Join Date: Nov 2004
Posts: 15
 

Default

Ahh...yea I was hoping to get to this at some point but I've been busy. Plus, for my purpose, this worked fine because everything sent out was sent in individual packages.

Thanks for the mod. Looks like it would work nice

I was thinking of extending this even further and having it add them into one box up until 150 pounds and then start a new box, manipulating them to get the best combo so you'd have the least number of boxes. But I'm busy right now with a few projects and my real job so I just don't have time...one of these days though it will happen.
__________________
xcart pro v3.5.12 [win]
Reply With Quote
  #16  
Old 04-04-2005, 07:35 PM
 
sabrina sabrina is offline
 

Advanced Member
  
Join Date: Feb 2003
Location: Indianapolis, IN., USA
Posts: 53
 

Default

UPS Realtime shipping rate calculation service returned the following error:
No Access Identification provided (errorcode: 250005)
Sorry, there are no available shipping methods for your location.:
__________________
X-CART GOLD: 4.0.14

Operating system Linux
Apache version 1.3.33 (Unix)
PERL version 5.8.1
PHP version 4.3.10
MySQL version 4.0.22-standard
Reply With Quote
  #17  
Old 04-04-2005, 07:38 PM
 
sabrina sabrina is offline
 

Advanced Member
  
Join Date: Feb 2003
Location: Indianapolis, IN., USA
Posts: 53
 

Default

UPS Debug Information
UPS Request
</Shipment>
</RatingServiceSelectionRequest>
UPS Response
<?xml version="1.0"?>
<RatingServiceSelectionResponse>
<Response>
<TransactionReference></TransactionReference>
<ResponseStatusCode>0</ResponseStatusCode>
<ResponseStatusDescription>Failure</ResponseStatusDescription>
<Error>
<ErrorSeverity>Hard</ErrorSeverity>
<ErrorCode>250005</ErrorCode>
<ErrorDescription>No Access Identification provided</ErrorDescription>
</Error></Response>
</RatingServiceSelectionResponse>
Error processing request at UPS
No Access Identification provided (errorcode: 250005)
Shipping Rates


Service: UPS
Error: No Access Identification provided (errorcode: 250005)
__________________
X-CART GOLD: 4.0.14

Operating system Linux
Apache version 1.3.33 (Unix)
PERL version 5.8.1
PHP version 4.3.10
MySQL version 4.0.22-standard
Reply With Quote
  #18  
Old 04-04-2005, 08:51 PM
 
PremiumPonyParts PremiumPonyParts is offline
 

Senior Member
  
Join Date: Dec 2004
Posts: 114
 

Default

Have you set up your UPS account and entered in yuor username and password?
__________________
Version 4.0.8
Reply With Quote
  #19  
Old 04-05-2005, 04:04 AM
 
sabrina sabrina is offline
 

Advanced Member
  
Join Date: Feb 2003
Location: Indianapolis, IN., USA
Posts: 53
 

Default

I was register with UPS OnLineб╝ Tools
__________________
X-CART GOLD: 4.0.14

Operating system Linux
Apache version 1.3.33 (Unix)
PERL version 5.8.1
PHP version 4.3.10
MySQL version 4.0.22-standard
Reply With Quote
  #20  
Old 09-24-2005, 10:05 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default

Quote:
Originally Posted by nick1628
I was thinking of extending this even further and having it add them into one box up until 150 pounds and then start a new box, manipulating them to get the best combo so you'd have the least number of boxes. But I'm busy right now with a few projects and my real job so I just don't have time...one of these days though it will happen.
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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
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 04:56 AM.

   

 
X-Cart forums © 2001-2020