Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

USPS Shipping Labels


xiloicta

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.

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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?

Link to comment
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.

Link to comment
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.

Link to comment
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">

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

  • 1 year later...

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.

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...

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...