this seems to be a very common thread amoung most php sites i have found. I am looking to get my hands on a working copy of the ups shipping rates tool script in php if anyone has one or knows where a good working copy is located please email me at subnero@peoplepc.com as i am trying to add ups shipping to a shopping cart that uses php scripting and ssl but have had no luck finding a script that will actually work. as i have no knowledge of being able to write this script myself i am in very dire need of some assitance. any help would be greatly appreciated. thanks sub
ups shipping tool
I've been searching for the same thing. I found this:
http://answers.google.com/answers/threadview?id=429083
and I think it works . You'll get a couple of syntax errors for missing brackets and mis-named functions, but they're easily fixed and hey, I got a number of some kind. Now need to test to see if the number actually means something...
I used the first example, btw.
ya i have tryed all of those codes AND none would work for what i am needing
Aside from the syntax errors (corrected in one of the responses further down the linked thread) I can't think of what would work better. Is it that you're not comfortable with the level of php required to implement it? It's actually pretty straightforward, per the example implentation given:
<?
require("ups.php");
$rate = new Ups;
$rate->upsProduct("1DM"); // See upsProduct() function for codes
$rate->origin("08033", "US"); // Use ISO country codes!
$rate->dest("90210", "US"); // Use ISO country codes!
$rate->rate("RDP"); // See the rate() function for codes
$rate->container("CP"); // See the container() function for codes
$rate->weight("17");
$rate->rescom("RES"); // See the rescom() function for codes
$quote = $rate->getQuote();
echo $quote;
?>
You just need to swap in the relevant zip codes, weight and desired shipping type (all the parameter options are listed within the actual class). Feed them in from $_POST-ed values, or retrieved from stored values in your customer database. And feed the resulting rate into your cart application rather than just echoing it.
What specifically do you need that this isn't providing?
Aside - I did run a brief test on this and it does appear to be pulling accurate UPS rates. I'm pretty psyched to give it a try.
Now if there was only one for FedEx...
I'm using this tool and getting the desired results.
There is one drawback, and that is maximum weight. If you choose UPS Ground
the max is 150 lbs. Anything over returns in summary "over max wt. for option" and no value.
How do you get a shipping estimate for over 150?
If you use the calculator at the shipping companies site (UPS) you divide the shipment into individual parcels that it than returns a rate.
Any way to do this with this tool?
After all, all you want is a rate estimate.
Amended info:
I should add that I had to add the separate UPS handling fee to the retrieved value, which I assume varies depending on the senders area.
DUH! how about feeding it 150lb and then multiplying the return by your_true_weight/150 ??
Isn't is a graduated rate?
and not necessarily $3.00 for 1 and $6.00 for 2?
probably, but all he wants is a guestimate. If they don't supply the tools then just have to hack with what you've got. You can refine it if there are standard one-off components that don't apply for multiple items, simply subtract those before you multiply.
Actually, there is probably a field for number of packages as per their website. Post the API documentation and we'll solve this.
Actually I've now given up on this solution and went ahead and set up an account on UPS and wrote a class to convert my query into XML and feed it to UPS, and get/parse the results. I also wrote a shipping class that splits up boxes depending on the weight (adds one item at a time and checks the weight, etc. until my preset limit is reached).
Reasons why the above solution is not good:
not officially supported by UPS - they could stop using that URL any time without warning (using the approved XML method means I should at least get notification if there's going to be a change)
doesn't account for dimensions. In MANY cases, when a package is larger/lighter, weight is adjusted higher based on package dimensions. You may have a 3 lb box that's an 18" cube, but the "dimensional weight" may be 25 lbs for a box of that size.
Unfortunately dimensional weight now applies to ground as well as air options - if you're not feeding in dimensions you're going to get artificially low shipping rates.
I don't want to post my 400-line UPS class without warning. Should I do so?
- Bob
Make it a zip and go ahead if you want to, or post it in the Code Critique Forum for peer review (but probably make it a zip still). Be very usefull for others I'm sure.
Oh yes, and a good move to make, going to the 'official procedure'. I tried to view their api but you have to register etc and I don't need it.
I tried coping with the xml offering at UPS -- I've registered, got my user keys etc.. -- but at present it's a tad over my head for quick usage. It will take me some time to work it out without a leg up or two.