Jump to content
bad_lemming

[Contribution] - USPS Methods

Recommended Posts

First off, Great contribution. Thank you.

 

Slight issue with a clean 2.2 rc2a install and this contribution loaded

 

Customers are having issues with paypal payments. Once they choose paypal and continue, they are taken to a login screen. After logging in they see a screen that wants them to review information, ie, funds source, address and contact info, then a continue button. The page has an error:

 

the error on the page says:

 

Fatal error: Class 'httpClient' not found in /home/XXXXXX/public_html/catalog/includes/modules/shipping/usps.php on line 269

 

I removed this contribution and loaded a flat rate shipping option - The error goes away and the transaction is successful.

Any thoughts?

 

 

Thanks in advance.

-billy

Share this post


Link to post
Share on other sites

Sorry to segue here, and Scott, excellent solution for the upper case shipping types problem, it was much appreciated.

 

Has anyone discovered a contrib or working on a piece to work with USPS Methods that will also accommodate dimensional shipping?

We have a number of items that fall under dimensional shipping. Currently I limit package weight but that really does not help, since some of the dimensional shipping items are very light, but large.

 

Also, anyone aware of an option to do a zero weight shipping calc?

Since I have tare weight and handling in my calcs, it will always add a minimal shipping charge at this point, which I do not want...on these items I will follow up orders with actually shipping costs and invoice them accordingly, major PITA and consumer of time.

 

Any leads would be much appreciated....

Share this post


Link to post
Share on other sites
First off, Great contribution. Thank you.

 

Slight issue with a clean 2.2 rc2a install and this contribution loaded

 

Customers are having issues with paypal payments. Once they choose paypal and continue, they are taken to a login screen. After logging in they see a screen that wants them to review information, ie, funds source, address and contact info, then a continue button. The page has an error:

 

the error on the page says:

 

Fatal error: Class 'httpClient' not found in /home/XXXXXX/public_html/catalog/includes/modules/shipping/usps.php on line 269

 

I removed this contribution and loaded a flat rate shipping option - The error goes away and the transaction is successful.

Any thoughts?

Thanks in advance.

-billy

 

what version are you using?

 

thanks!

 

Scott

Share this post


Link to post
Share on other sites
what version are you using?

 

3.0 now :)

 

Just noticed the updated version. Loaded up and it works great.

 

Thank you,

-billy

Share this post


Link to post
Share on other sites

OK just noticed an issue while testing the cart with some pricing changes reflecting specials I am offering on a number of products.

 

It appears that only the first of the list of items is being counted now in the weight calculations, so I end up with incorrect postage.

 

I did not recall seeing anything regarding this while perusing the thread from my last update.

 

Looking at contrib history I am using 2.9 (fixed).

 

Anyone familair with this issue?

Share this post


Link to post
Share on other sites
Also, anyone aware of an option to do a zero weight shipping calc?

Since I have tare weight and handling in my calcs, it will always add a minimal shipping charge at this point, which I do not want...on these items I will follow up orders with actually shipping costs and invoice them accordingly, major PITA and consumer of time.

 

Any leads would be much appreciated....

 

In the code there is a section which states that USPS does not accept 0 weight; however, you could mod that section of the code to accomplish what you want, I think. Here's the code that mods 0 weights to round up.

 

// usps doesnt accept zero weight
  $shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);
  $shipping_pounds = floor ($shipping_weight);
  $shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight)));
  $this->_setWeight($shipping_pounds, $shipping_ounces);

 

thanks for using this addon!

 

Scott

Share this post


Link to post
Share on other sites
In the code there is a section which states that USPS does not accept 0 weight; however, you could mod that section of the code to accomplish what you want, I think. Here's the code that mods 0 weights to round up.

 

// usps doesnt accept zero weight
  $shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);
  $shipping_pounds = floor ($shipping_weight);
  $shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight)));
  $this->_setWeight($shipping_pounds, $shipping_ounces);

 

thanks for using this addon!

 

Scott

 

Scott,

 

Not quite what I want as a result.

 

Rather than round up to a minimum weight, I want to bypass that zero weight from going to the $shipping_weight, and be able to flag the invoice and/or open a pop up with the message of 'The shipping for item X cannot be calculated thru the store interface, we will contact you will shipping details for the item and invoice you appropriately'

 

I had a bit more coded solution (not php/mysql savvy yet, but I write in java, struts, ruby, ms-sql and a proprietary language at the office)

 

For all intensive purposes, the item(s) will not be in the tally calculated for shipping, but will be billed at their price accordingly.

 

Something like this:

// item zero wight USPS shipping calc bypass and flag

 

def item = ;

def index = 0;

foreach item (set item = item_model(to vector[attributes]))

{

def $shipping_weight = ;

if (item_model[element of shipping weight] = 0)

{

message(to_invoice(), html!to_browser() : 'The shipping for item X cannot be calculated thru the store interface, we will contact you will shipping details for the item and invoice you appropriately')

}

else

{usual USPS shipping calc here}

set index = (index+1);

 

Make any sense?

Like I said I am not php savvy, so this is simply a model mock up.

 

 

Corey

Share this post


Link to post
Share on other sites

That looks like a good start Corey, here's a few edits that I think make it php friendly, but I'm no expert either.

 

// item zero weight USPS shipping calc bypass and flag

def item = '';
def index = '0';
foreach item (set item = item_model(to vector[attributes])) 
 {
   def $shipping_weight = '';
   if (item_model[element of shipping weight] == '0')
		 {
	  message(to_invoice(), html!to_browser() : 'The shipping for item X cannot be calculated thru the store interface, we will contact you will shipping details for the item and invoice you appropriately')
		 }
   else
		{usual USPS shipping calc here}
set index = (index+1);

 

I think I see where you are going... let me know your progress here...

 

Scott

Share this post


Link to post
Share on other sites

Love It!

 

Started having an issue with FIRST-CLASS MAIL INT about two weeks ago.

 

I just updated to 3.0. Domestic works fine. All other International methods work fine.

 

 

When set as the only option, FIRST-CLASS MAIL INT returns "An error occured with the USPS shipping calculations.

If you prefer to use USPS as your shipping method, please contact the store owner."

 

Any Ideas

 

Thanks in advance.

Share this post


Link to post
Share on other sites

Thank you for this great contribution. I was using it for a few months till recently and most of my customers chose to ship via USPS.

 

For about a month though I've noticed that the checkout_shipping.php page is very slow to load (i'm talking about minutes!) when the USPS Methods is enabled at time. I've lost a few customers that way. The email with the quote response shows that USPS is sending the quote within seconds of the request. I contacted their customer service and they don't have any problem on their end. I've updated to the latest version and still get the same problem.

 

I've disabled the USPS module and I get my quotes from FEDEX in no time now. The problem is that many customers are used to using USPS and I'd like to expand internationally and USPS seems to be the best shipping method for that.

 

Has anyone encountered this problem on their site? Any ideas where the problem may be coming from and how I could solve it?

 

Thank you

Share this post


Link to post
Share on other sites
Thank you for this great contribution. I was using it for a few months till recently and most of my customers chose to ship via USPS.

 

For about a month though I've noticed that the checkout_shipping.php page is very slow to load (i'm talking about minutes!) when the USPS Methods is enabled at time. I've lost a few customers that way. The email with the quote response shows that USPS is sending the quote within seconds of the request. I contacted their customer service and they don't have any problem on their end. I've updated to the latest version and still get the same problem.

 

I've disabled the USPS module and I get my quotes from FEDEX in no time now. The problem is that many customers are used to using USPS and I'd like to expand internationally and USPS seems to be the best shipping method for that.

 

Has anyone encountered this problem on their site? Any ideas where the problem may be coming from and how I could solve it?

 

Thank you

 

did you delete all other usps modules before installing usps methods? if not, it causes a conflict.

 

Scott

Share this post


Link to post
Share on other sites
did you delete all other usps modules before installing usps methods? if not, it causes a conflict.

 

Scott

 

 

Scott,

 

Thanks for the suggestion.

 

I might not have done that, though I don't have any other usps modules loaded. I'll go ahead and delete usps methods and do a fresh install. I'll monitor the site for a while to see if the problem appears again.

 

Peace,

 

Suhail

Share this post


Link to post
Share on other sites

Also deactivate the stock usps in the admin panel.

 

 

Be very careful on how you "delete" the contrib!

Follow the documentation in reverse order and remove all code added in that order.

You should have a clean slate to begin from again.

 

BACK UP BACK UP BACK UP

Share this post


Link to post
Share on other sites

I have USPS Methods 3.0 installed. I just noticed that, near the top of the shipping modules page in Admin, I am getting the following error: "Parse error: syntax error, unexpected T_GLOBAL, expecting ')' in /home/danielm2/public_html/catalog/admin/modules.php(217) : eval()'d code on line 1." It's been a while since I installed the module, and I don't recall seeing that error before now, so either I've been blind or it's something that started recently. Although I have not made any changes to catalog/admin/modules.php since installing the USPS Methods contribution, I have made numerous changes to other files, including recent ones for the Handling Fee contribution (http://www.oscommerce.com/community/contributions,1190/category,6/search,cod+fee), which is the only other contribution I've added that affects shipping and handling.

 

The thing is that the module seems to be working fine. Rates are calculated properly, and no other problems have cropped up. Can anyone give me some idea on why that error is appearing? Line one of modules.php is <?PHP , so I'd guess that the problem is actually someplace else in the code. I can post the entire code of the file, if that would help in identifying the problem.

Share this post


Link to post
Share on other sites

alright so i'm having quite a strange issue. a number of OSC stores i've set up just started returning $0.00 for First Class Domestic, but correct prices for all other selected methods. that said, i use a "master set" when i install OSC now (containing all my mods) and other stores from the same master set are not having the issue. also, of those on the same host even, some are having the issue, some are not.

 

i've tried pulling the USPS module file (/includes/modules/shipping/usps.php) from working stores and replacing it on the non-working, but it still returns the zero price.

 

ANY IDEAS? i need to resolve this ASAP. thanks!

Share this post


Link to post
Share on other sites
alright so i'm having quite a strange issue. a number of OSC stores i've set up just started returning $0.00 for First Class Domestic, but correct prices for all other selected methods. that said, i use a "master set" when i install OSC now (containing all my mods) and other stores from the same master set are not having the issue. also, of those on the same host even, some are having the issue, some are not.

 

i've tried pulling the USPS module file (/includes/modules/shipping/usps.php) from working stores and replacing it on the non-working, but it still returns the zero price.

 

ANY IDEAS? i need to resolve this ASAP. thanks!

 

Do all your stores have the addition to includes/functions/general.php ?

 

Scott

Share this post


Link to post
Share on other sites
I have USPS Methods 3.0 installed. I just noticed that, near the top of the shipping modules page in Admin, I am getting the following error: "Parse error: syntax error, unexpected T_GLOBAL, expecting ')' in /home/danielm2/public_html/catalog/admin/modules.php(217) : eval()'d code on line 1." It's been a while since I installed the module, and I don't recall seeing that error before now, so either I've been blind or it's something that started recently. Although I have not made any changes to catalog/admin/modules.php since installing the USPS Methods contribution, I have made numerous changes to other files, including recent ones for the Handling Fee contribution (http://www.oscommerce.com/community/contributions,1190/category,6/search,cod+fee), which is the only other contribution I've added that affects shipping and handling.

 

The thing is that the module seems to be working fine. Rates are calculated properly, and no other problems have cropped up. Can anyone give me some idea on why that error is appearing? Line one of modules.php is <?PHP , so I'd guess that the problem is actually someplace else in the code. I can post the entire code of the file, if that would help in identifying the problem.

 

1. check the troubleshooting section of the installation guide

2. also do a search on this form for your error and I think you'll find some ideas

 

Scott

Share this post


Link to post
Share on other sites
Do all your stores have the addition to includes/functions/general.php ?

 

Scott

 

what bit of code should i be looking for in general.php? i compared the general.php files from a working and non-working store from my "master set" and they're identical.

Share this post


Link to post
Share on other sites
what bit of code should i be looking for in general.php? i compared the general.php files from a working and non-working store from my "master set" and they're identical.

 

includes/functions/general.php

 

// USPS Methods 3.0
// Alias function for Store configuration values in the Administration Tool
 function tep_cfg_select_multioption($select_array, $key_value, $key = '') {
for ($i=0; $i<sizeof($select_array); $i++) {
  $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
  $string .= '<br><input type="checkbox" name="' . $name . '" value="' . $select_array[$i] . '"';
  $key_values = explode( ", ", $key_value);
  if ( in_array($select_array[$i], $key_values) ) $string .= ' CHECKED';
  $string .= '> ' . $select_array[$i];
}
$string .= '<input type="hidden" name="' . $name . '" value="--none--">';
return $string;
 }

 

also, this should be added to modules.php in all stores

 

catalog/admin/modules.php

*****************************************
Find This code somewhere around line 43:
*****************************************

if (tep_not_null($action)) {
switch ($action) {
  case 'save':
	while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {

***********************************************
INSERT THE FOLLOWING CODE AFTER THE ABOVE LINE:
***********************************************

	  if( is_array( $value ) ){
	  $value = implode( ", ", $value);
	  $value = ereg_replace (", --none--", "", $value);
		}

****************************
SO IT SHOULD LOOK LIKE THIS:
****************************

if (tep_not_null($action)) {
switch ($action) {
  case 'save':
	while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
	  if( is_array( $value ) ){
	  $value = implode( ", ", $value);
	  $value = ereg_replace (", --none--", "", $value);
		}
	  tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
	}
	tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']));
	break;
  case 'install':

 

Scott

Share this post


Link to post
Share on other sites
includes/functions/general.php

 

// USPS Methods 3.0
// Alias function for Store configuration values in the Administration Tool
 function tep_cfg_select_multioption($select_array, $key_value, $key = '') {
for ($i=0; $i<sizeof($select_array); $i++) {
  $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
  $string .= '<br><input type="checkbox" name="' . $name . '" value="' . $select_array[$i] . '"';
  $key_values = explode( ", ", $key_value);
  if ( in_array($select_array[$i], $key_values) ) $string .= ' CHECKED';
  $string .= '> ' . $select_array[$i];
}
$string .= '<input type="hidden" name="' . $name . '" value="--none--">';
return $string;
 }

 

also, this should be added to modules.php in all stores

 

catalog/admin/modules.php

*****************************************
Find This code somewhere around line 43:
*****************************************

if (tep_not_null($action)) {
switch ($action) {
  case 'save':
	while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {

***********************************************
INSERT THE FOLLOWING CODE AFTER THE ABOVE LINE:
***********************************************

	  if( is_array( $value ) ){
	  $value = implode( ", ", $value);
	  $value = ereg_replace (", --none--", "", $value);
		}

****************************
SO IT SHOULD LOOK LIKE THIS:
****************************

if (tep_not_null($action)) {
switch ($action) {
  case 'save':
	while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
	  if( is_array( $value ) ){
	  $value = implode( ", ", $value);
	  $value = ereg_replace (", --none--", "", $value);
		}
	  tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
	}
	tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']));
	break;
  case 'install':

 

Scott

 

i updated the module to USPS Methods v3 and added this bit of code to general.php (the other bit was already in place). still seeing $0.00 for First Class rate, but all the other selected methods (Priority, Media) are working/displaying prices fine. any help on resolving this is greatly appreciated!

 

Sean

Share this post


Link to post
Share on other sites
i updated the module to USPS Methods v3 and added this bit of code to general.php (the other bit was already in place). still seeing $0.00 for First Class rate, but all the other selected methods (Priority, Media) are working/displaying prices fine. any help on resolving this is greatly appreciated!

 

Sean

 

Thanks Sean,

 

I'm beginning to wonder if USPS changed their 1st Class title or something, because if the others are working, 1st class should work too.

 

Scott

Share this post


Link to post
Share on other sites
Thanks Sean,

 

I'm beginning to wonder if USPS changed their 1st Class title or something, because if the others are working, 1st class should work too.

 

Scott

 

how would i research this? my client is starting to get upset as they just launched a new product and really need to have first class available to customers. thanks for the help!

 

sean

Share this post


Link to post
Share on other sites
how would i research this? my client is starting to get upset as they just launched a new product and really need to have first class available to customers. thanks for the help!

 

sean

 

go to usps' website - search for developer api or something like this... it might be better to go ahead with the stock osC usps.

 

Scott

Share this post


Link to post
Share on other sites

:blush: Sorry olsonsp4c, but I changed the module to USPS v3 API. This allows for many more options not available with the v2 API. You can now have FLAT RATE and LETTERS!!!!! I listed it as an alpha, so yours is still good.

 

BTW, to answer your question, try the USPS Methods 4.0 I just uploaded. My primary shipping is First Class letters and it seems to be working fine so far. Give it a try and look at the options in USPS.php. To install, just replace USPS.php in /includes/modules/shipping

 

To see it working in my store, go to http://epicdecals.com ;)

 

I'm just hoping I didn't mess up anything.

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

×