Jump to content
Latest News: (loading..)
xiloicta

USPS Shipping Labels

Recommended Posts

Fixing 2 digit state.

 

Add below //directory where all support files are

 

//Gets the return & billing address two digit state code

$shipping_zone_query = tep_db_query("select z.zone_code from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where zone_name = '" . $order->delivery['state'] . "' AND c.countries_name = '" . $order->delivery['country'] . "' AND c.countries_id = z.zone_country_id");

$shipping_zone = tep_db_fetch_array($shipping_zone_query);

$shipping_zone_code = ($shipping_zone['zone_code'] == '' ? $order->delivery['state'] : $shipping_zone['zone_code']); // if the query result was empty, then use the state name

if ($order->billing['state'] == $order->delivery['state']) { // if billing and shipping states are the same, then we can save a query

$billing_zone_code = $shipping_zone_code;

} else {

$billing_zone_query = tep_db_query("select z.zone_code from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where z.zone_name = '" . $order->billing['state'] . "' AND c.countries_name = '" . $order->billing['country'] . "' AND c.countries_id = z.zone_country_id");

$billing_zone = tep_db_fetch_array($billing_zone_query);

$billing_zone_code = ($billing_zone['zone_code'] == '' ? $order->billing['state'] : $billing_zone['zone_code']); // if the query result was empty, then use the state name

}

 

Replace

<input type="hidden" name="form.deliveryState" value= "<?php echo $order->delivery['state'];?>" id="stateTo">

 

With

//State

<input type="hidden" name="form.deliveryState" value= "<?php echo $shipping_zone_code;?>" id="stateTo">

 

I haven't figured out the result if country is not us. But this fixes the immediate problem.

Share this post


Link to post
Share on other sites

I have it working although it is not picking up my Company Name (it used to). I think the problem may be that my USPS account is personal and not business. I have sent them an email asking how to fix the problem. I can go into edit mode after the fields are filled in and add the name but that is time consuming. At least I don't have to enter the shipping address.

 

I would like to thank everyone for all the hard work. I still can't believe that our tax dollars are being used to change the shipping page into a frilly hard to read page. No wonder the post office is losing money.


-- A ship in a harbor is safe, but that is not a ships ultimate purpose.

Share this post


Link to post
Share on other sites

Just in case anyone else is having a problem with company name. I fixed the company name. I set up a new account with USPS that is flagged as business and it let me add a Company Name. The old version of usps_php picked up the return address values from the configuration file. The new version is using the info on the USPS account.


-- A ship in a harbor is safe, but that is not a ships ultimate purpose.

Share this post


Link to post
Share on other sites

Hello all, new to this forum and had the same issue that the OP had with our OSC site. I had our web developer help us and this is the fix he came up with. We are using zone rates so some of the previous posters may be using a different code. It sure was a PITA no thanks to USPS.USPS Fix for OSCommerce.txt

Share this post


Link to post
Share on other sites

Wow, I am not live on the web. I was considering using this module but I think I will just use click and ship and Paypal. Easy enough for me. The only drawback to Paypal is the service charge. But it is worth not having the headaches.

Share this post


Link to post
Share on other sites

I downloaded the update and everything works except the first and last name in the delivery address is not being populated. At least I have all the other information going through. Anyone have a fix for this?

Share this post


Link to post
Share on other sites

I downloaded the update and everything works except the first and last name in the delivery address is not being populated. At least I have all the other information going through. Anyone have a fix for this?

 

around line 149 in usps_ship.php find:

$arr = explode(" ", $order->customer['name'], 2);

 

And replace it with this:

$arr = explode(" ", $order->delivery['name'], 2);

 

It was using the customer name instead of the delivery name. If they are the same, you don't see the problem. Thanks for the catch.


-- A ship in a harbor is safe, but that is not a ships ultimate purpose.

Share this post


Link to post
Share on other sites

Tried it but still no first or last name sent to the form. Here is what I have in that area:

 

 

$arr = explode(" ", $order->delivery['name'], 2);

$myFirstName = $arr[0];

$myLastName = $arr[1];

$myFirstName = ucfirst(strtolower($myFirstName));

if(strlen($myFirstName) < 3 ){

$myFirstName = substr($order->customer['name'], 0, strrpos( $order->customer['name'], ' ') );

}

 

everything else is exported to the USPS form correctly.

Share this post


Link to post
Share on other sites

Here is a bit more code where I think the problem is.

 

<?

$arr = explode(" ", $order->delivery['name'], 2);

$myFirstName = $arr[0];

$myLastName = $arr[1];

$myFirstName = ucfirst(strtolower($myFirstName));

if(strlen($myFirstName) < 3 ){

$myFirstName = substr($order->customer['name'], 0, strrpos( $order->customer['name'], ' ') );

}

 

?>

<input type="hidden" name="form.deliveryFirstName" value="<?php echo $myFirstName; ?>" id="tNameFirstTo">

<input type="hidden" name="form.deliveryLastName" value="<?php echo $myLastName; ?>" id="tNameLastTo">

<input type="hidden" name="form.deliveryCompanyName" value="<?php echo $order->delivery['company']; ?>" id="tCompanyTo">

<input type="hidden" name="form.deliveryAddressOne" value="<?php echo $order->delivery['street_address']; ?>" id="tAddress1To">

<input type="hidden" name="form.deliveryAddressTwo" value="<?php echo $order->delivery['suburb']; ?>" id="tAddress2To">

<input type="hidden" name="form.deliveryCity" value="<?php echo $order->delivery['city']; ?>" id="tCityTo">

Share this post


Link to post
Share on other sites

Ignore the above two post from me. The problem is with my test server. It works perfectly with my live site. Not sure why the difference.

Share this post


Link to post
Share on other sites

It works perfectly with my live site. Not sure why the difference.

For rare cases, you'll also need to make this change, too:

// change this
$myFirstName = substr($order->customer['name'], 0, strrpos( $order->customer['name'], ' ') );

// to this
$myFirstName = substr($order->delivery['name'], 0, strrpos( $order->delivery['name'], ' ') );


Don

Portland, OR USA

Share this post


Link to post
Share on other sites

I changed the code for handling short first names like "J. Robert Fox". The existing code generated "J. Robert" for the first name and "Robert Fox" for the last name.

 

Around line 158:

$arr = explode(" ", $order->delivery['name'], 2);
$myFirstName = $arr[0];
$myLastName = $arr[1];
$myFirstName = ucfirst(strtolower($myFirstName));
if (strlen($myFirstName) < 3 ){
  // short first name, see if last name has multiple parts
  $arr = explode(" ", $myLastName, 2);
  if (strlen($arr[1])) {
  $myFirstName .= ' ' . $arr[0];
  $myLastName = $arr[1];
  }
}

Even this code, however, isn't going to work well with a name like "J. Roberts Jr." but I'm not going to fuss with it any more right now.


Don

Portland, OR USA

Share this post


Link to post
Share on other sites

Im so tired of them "updating" their site and having everything break!!! Ahhh!! They really changed this form this time...Solutions?

Share this post


Link to post
Share on other sites

Ah, just when I thought that all was okay with the latest USPS update...

Labels export is not working so I'm back to copy/paste of customer/shipping information.

We ship international packages a lot and the USPS has now created dropdown lists for foreign postal codes and many codes are missing.

The only way around this is now to create the label selecting an incorrect postal code and then edit the label on the USPS website.

While in the edit screen, the pulldown postal code field becomes a text field so I can enter the correct postal code.

Why oh why is it that the USPS can never make things easier??

I hope someone comes up with a fix for the USPS label module soon.

Share this post


Link to post
Share on other sites

I import my orders into paypal multi-order shipping on days when I have a bunch (doesn't work for international orders) but the days I only have a few priority mail shippables this was the perfect solution.

 

Maybe when I get back from vacation I'll take a look at it, but someone that is more fluent in this module could probably do it better and definitely faster.

Share this post


Link to post
Share on other sites

I tried using the new USPS page just typing an address in and it would not let me go to the next page, WTF. Maybe it was just firefox will try another browser later.

Share this post


Link to post
Share on other sites

That new postal page is terrible, I emailed USPS to complain, but that is long shot.

 

I've been fiddling with this contribution trying to get it going again (I made the last change last year) but USPS made some drastic changes this time. Hopefully someone with more experience will jump on this and help all of us out.

Share this post


Link to post
Share on other sites

I shot them an email too. Typical government, trying to make it easier for consumers (which they didn't) screw their business customers that provide more revenue. :D

Share this post


Link to post
Share on other sites

USPS never sanctioned POSTing to their site as this addon did, they simply no longer accept POST'd data. Unfortunately a different solution will need to be created.


-Dave

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×