Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

rate V4 changes to usps.php for osc2.2


keenanj

Recommended Posts

Is anyone working on modifying the usps.php to work with rate v4 on OCS 2.2?

 

I tried the USPS methods contrib and its a no go.

 

I just need basic usps shipping for priority and express and like many i have a highly modified v2.2 over 10 years of tweaks

Link to comment
Share on other sites

http://addons.oscommerce.com/info/8327

 

The contrib found here will work on a 2.2 shop. There's just a few little differences between the 2.2 and 2.3.1 code that you'll need to catch to get it working right (admin/modules.php comes to mind).

 

 

The simplest version is at the bottom, with added features as you go higher up. If you choose one with most of the features, then skip the modifications to the checkout_shipping file and it's associated language file, unless you have jquery installed in your shop (which is a standard part of 2.3.1).

Link to comment
Share on other sites

I i try to enable the module I get the following error in the admin

 

Warning: call_user_func(tep_get_zone_class_title) [function.call-user-func]: First argument is expected to be a valid callback in /home/content/k/e/e/keenanj/html/store/catalog/admin/includes/functions/general.php on line 1229

 

and this one in the user interface

 

Fatal error: Cannot instantiate non-existent class: httpclient in /home/content/k/e/e/keenanj/html/store/catalog/includes/modules/shipping/usps.php on line 303

Edited by keenanj
Link to comment
Share on other sites

all i really need to do is modify _usps.php section for the new api

 

function getPrice() {

$str = '<RateRequest USERID="' . $this->user . '" PASSWORD="' . $this->pass . '">';

$str .= '<Package ID="0">';

$str .= '<Service>' . $this->service . '</Service>';

$str .= '<ZipOrigination>' . $this->orig_zip . '</ZipOrigination>';

$str .= '<ZipDestination>' . $this->dest_zip . '</ZipDestination>';

$str .= '<Pounds>' . $this->pounds . '</Pounds>';

$str .= '<Ounces>' . $this->ounces . '</Ounces>';

$str .= '<Container>' . $this->container . '</Container>';

$str .= '<Size>' . $this->size . '</Size>';

$str .= '<Machinable>' . $this->machinable . '</Machinable>';

$str .= '</Package>';

$str .= '</RateRequest>';

$str = $this->server . '?API=Rate&XML=' . urlencode($str);

Link to comment
Share on other sites

I got usps module for OCS2.2 working with postal service v4 API

 

This took me 2 days of work.

 

all you need to do is modify the catalog/includes/classes/_usps.php

 

with this section of code

 

function getPrice() {

$str = '<RateV4Request USERID="' . $this->user . '">';

$str .= '<Revision/>';

$str .= '<Package ID="0">';

$str .= '<Service>' . $this->service . '</Service>';

$str .= '<ZipOrigination>' . $this->orig_zip . '</ZipOrigination>';

$str .= '<ZipDestination>' . $this->dest_zip . '</ZipDestination>';

$str .= '<Pounds>' . $this->pounds . '</Pounds>';

$str .= '<Ounces>' . $this->ounces . '</Ounces>';

$str .= '<Container/>';

$str .= '<Size>' . $this->size . '</Size>';

$str .= '<Machinable>' . $this->machinable . '</Machinable>';

$str .= '</Package>';

$str .= '</RateV4Request>';

$str = $this->server . '?API=RateV4&XML=' . urlencode($str);

$fp = fopen($str, "r");

if (!$fp) {

$body = 'Connection Failed';

} else {

while(!feof($fp)){

$result = fgets($fp, 500);

$body.=$result;

 

}

fclose($fp);

}

if (ereg("<Rate>", $body)) {

$split = split("<Rate>", $body);

$body = split("</Rate>", $split[1]);

$price = $body[0];

return($price);

} else {

return($body);

}

Edited by Jan Zonjee
Link to comment
Share on other sites

  • 2 weeks later...

Hi Jeff :

Am I ADDING the above code somewhere, or replacing some that is already there ? I've been using OSC for over 10 years and almost never have to do any programming; so I'm not so good at it. For those of us who only need a very simplistic checkout system, OSC really fits the bill !

I see in my original usps.php file (from OSC2.2) that there is some similar language about halfway down so I'm guessing I might start replacing there; but cannot see a similar place to end the new code. Thanks for any input you could provide.

Link to comment
Share on other sites

  • 2 weeks later...

@@fulluvscents How do I update the language? My client needs USPS to show up as USPS Parcel Post in their orders, for example. I tried to edit the usps.php file and reinstall. I tried to edit just the db entries. Neither of those worked, rendering the entire module broken and not showing up when checking out.

 

Any help would be appreciated.

Edited by pfilias
Link to comment
Share on other sites

  • 2 weeks later...

Here's the debate...

 

Use http://addons.oscommerce.com/info/8327 or http://addons.oscommerce.com/info/8403?

 

I personally tried 8403 to the letter and all I get a blank page for checkout_shipping... However, the weight of the product displays when I moved up into the other upgrades. Curious...

 

The min/max/handing dialog goes wacky, perhaps a database issue? I check one of the shipping methods and return to check it, and all I get is a minimum "Parcel Post" and the 70lbs. max jumps to the handling.

 

Any ideas?

Link to comment
Share on other sites

OK, maybe Jetta can help here...

 

I use Uniform Server to beta test my site before going live. I used http://addons.oscommerce.com/info/8403 to update the USPS functions and the above occurred in my last post. So, I figured I would go with a live swap out of the files and test it from there (what the heck!)... It works. Don't know why, other than that's a good thing.

 

My provider actually has a older version of PHP running than my version in Uniform Server and MySQL is only a fraction of a version out from each other. I don't see that being the issue.

 

Just thought I would post this little tip to help those that might be trying to resolve their install.

Link to comment
Share on other sites

I had the same problem as some others here, with the httpclient class not being found. I got the error when getting the postback from paypal to the express.php file.

 

I added in an include line, following the advice from: http://www.oscommercecoders.com/fatal-error-class-httpclient-not-found-in-homexxxxxxxpublic_htmlmyshopincludesmodulesshippingups-php-on-line-265/

 

and now things seem to be happy.

Link to comment
Share on other sites

Your module installed beautifully with no problems. Thank You!

 

Now, I do have a couple of questions:

 

1. Priority Mail International Flat Rate SMALL BOX does not display. It works fine with Domestic Priority Mail Flat Rate small box. I also tested to verify it is not dependent on country to make sure it wasn't a problem with a particular country.

 

It may have displayed and stopped working when I switched between Retail and Online. Are there any configuration fields in the database that may have gotten screwed up or corrupted by changing between Retail and Online and back?

 

I also played with product dimensions and weights, but that has no effect.

 

I did uninstall usps.php and redid the configuration, but that did not help. - Which is why I am wondering about configuration fields in the database.

 

NOTE: The module installed WITHOUT any changes, so it isn't a typo in the module itself unless it's in the distribution.

 

2. Is there any provision in this module for handling product / shipping dimensions? If not, any clever ways to handle them?

 

3. It appears that the estimated delivery time is returned and I just need to modify my site to display the time estimate. Is that correct?

 

4. If you want to place a test order to see what I am talking about, feel free to do so. You will see the problem before you are asked to pay.

 

https://xeonixinc.com

 

Thanks in advance for any guidance you might offer.

Link to comment
Share on other sites

  • 5 months later...

First off, Thank you - I could not dream of writing such an amazing module, and the fact I'm having a problem installing it has no bearing on my gratitude for the hard work that went into developing it.

 

I am running osc 2.3 , and have installed : USPS Rates ServerV4 (for osc2.2)

 

I didn't realize I was running 2.3 and not 2.2 at the time of install.

 

I followed all the instructions, modified the required files, then added the new ones.

 

I've received my User ID and Password from USPS -- turned around and emailed them back asking to move me to production, which they did.

 

I verified the url they sent me, and it matches yours.

 

Problem is - I go into the admin screen, edit the module, select the services, place min and max values, click save -- and nothing is saved.

 

as a result, obviously, no shipping methods are displayed.

 

Any chance someone knows how to fix this problem? Thank you in advance for any suggestions.

 

**as an added note, i do not have a /includes/classes/_usps.php file - If I need it, where do I get it from - it wasn't included in the download that I can see. - Thank you again.

Edited by beuki
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...