Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] - USPS Methods


Recommended Posts

Apparently, I have no trouble with the configuration table structure, because it appears to be working. I need to do some more testing, but good job!!

 

I've got those double asterisks after First Class International, and wondered if you knew how to fix this on Domestic:

 

 

 

As you can see, it's putting a "1" at the head of the transit string, with no value for the "Day". I believe Priority Mail is pretty much the same transit time as First Class for Domestic, but I can't remember for sure. Anyway ... help is appreciated.

 

 

EDIT: Hmm ... didn't see that a.forever had the same error before I posted.

 

I had the same problem you have to edit in catalog\includes\modules\shipping\usps.php

 

Depending which shipping method will offer, for me it just was priority mail starting on line 518

 

$postage = $postage + $this->handling[1];

break;

case 'Priority Mail':

$time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);

$time = $tregs[1];

if ($time == '' || $time == 'No Data') {

$time = MODULE_SHIPPING_USPS_TEXT_PRIORITY;

} elseif ($time == '1') {

$time .= MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;

} else {

$time .= MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

 

Change line 521 to

 

$time = ereg('<Day>(.*)</Day>', $transresp[$service], $tregs);

 

and everyting will work fine.

 

I was than able to change my note to customers to something like: (2-4 days all states even West Coast, we ship Monday/Tuesday)

by changing the file catalog\includes\languages\english\modules\shipping\usps.php

 

Hope this helps

 

Wolfgang

Link to comment
Share on other sites

OK - please note the Fatal Error in the above post is "usps.php." ;) I think the "tep_round_up" function was something we added to the new USPS Methods. Help?

 

 

Yes see #4 in the readme file in USPS 5.0.3 in the contributions

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

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

I had the same problem you have to edit in catalog\includes\modules\shipping\usps.php

 

Depending which shipping method will offer, for me it just was priority mail starting on line 518

 

$postage = $postage + $this->handling[1];

break;

case 'Priority Mail':

$time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);

$time = $tregs[1];

if ($time == '' || $time == 'No Data') {

$time = MODULE_SHIPPING_USPS_TEXT_PRIORITY;

} elseif ($time == '1') {

$time .= MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;

} else {

$time .= MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

 

Change line 521 to

 

$time = ereg('<Day>(.*)</Day>', $transresp[$service], $tregs);

 

and everyting will work fine.

 

I was than able to change my note to customers to something like: (2-4 days all states even West Coast, we ship Monday/Tuesday)

by changing the file catalog\includes\languages\english\modules\shipping\usps.php

 

Hope this helps

 

Wolfgang

 

Yes a minor issue with the version I posted, it was pulling both the laugauage file and a transit time from USPS.. I am about to test an improved version.. stay tuned

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

As promised, progress..

 

January 6th, 2011 by Fulluv Scents

basic fine tuning for USPS V3 & V4 requirements

WORK IN PROGRESS - improvements forthcoming

 

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

 

NOTES 5.1.0

 

1. Handling fees for Domestic Rates only

 

2. Insurance option in this module is not working

 

3. Domestic transit times pulled from language file, International pulled from USPS

 

4. TODO: Insurance for Domestic, Handling for International, Trade and Register Marks

transit times all pulled from USPS

 

=======

IF RUNNING 5.X.X successfully you should only have to:

1. Remove USPS module from within admin panel

 

2. Replace the usps.php included to:

catalog\includes\modules\shipping\usps.php

 

3. Install and setup the module

===============

If running any version 4.X.X or older follow instructions in the README

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

Yes see #4 in the readme file in USPS 5.0.3 in the contributions

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

Yes, the problem is that I did that. I just verified the "general.php" file, too - the Greg Deeth function is in there in the place defined in #4 of the readme file.

Edited by TomB01
Link to comment
Share on other sites

I had the same problem you have to edit in catalog\includes\modules\shipping\usps.php

 

Depending which shipping method will offer, for me it just was priority mail starting on line 518

 

$postage = $postage + $this->handling[1];

break;

case 'Priority Mail':

$time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);

$time = $tregs[1];

if ($time == '' || $time == 'No Data') {

$time = MODULE_SHIPPING_USPS_TEXT_PRIORITY;

} elseif ($time == '1') {

$time .= MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;

} else {

$time .= MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

 

Change line 521 to

 

$time = ereg('<Day>(.*)</Day>', $transresp[$service], $tregs);

 

and everyting will work fine.

 

I was than able to change my note to customers to something like: (2-4 days all states even West Coast, we ship Monday/Tuesday)

by changing the file catalog\includes\languages\english\modules\shipping\usps.php

 

Hope this helps

 

Wolfgang

It works perfectly - thank you!

Link to comment
Share on other sites

As promised, progress..

 

January 6th, 2011 by Fulluv Scents

basic fine tuning for USPS V3 & V4 requirements

WORK IN PROGRESS - improvements forthcoming

 

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

 

NOTES 5.1.0

 

1. Handling fees for Domestic Rates only

 

2. Insurance option in this module is not working

 

3. Domestic transit times pulled from language file, International pulled from USPS

 

4. TODO: Insurance for Domestic, Handling for International, Trade and Register Marks

transit times all pulled from USPS

 

=======

IF RUNNING 5.X.X successfully you should only have to:

1. Remove USPS module from within admin panel

 

2. Replace the usps.php included to:

catalog\includes\modules\shipping\usps.php

 

3. Install and setup the module

===============

If running any version 4.X.X or older follow instructions in the README

 

This is great - can't wait! Thank you!

Link to comment
Share on other sites

This is great - can't wait! Thank you!

 

 

It is coming together. I've got a working version for RateV4 and IntlRateV2. Insurance is working (both domestic and international). Transit times are being pulled from USPS for both international and domestic. International handling has been added. Many options. But, as stated, it is a work in progress and is being tested one thing at a time. When all is said and done, this should be the best USPS module yet. I'm excited. I just hope it works as well for everyone else as it is working for me so far. Hopefully, we'll get some updates for testing, but it will be a little while before we have a complete package. Just thought I'd pop in and say hi, and make a notation that we are going to be ready for May. woohoo.

Link to comment
Share on other sites

Here's what has been done so far on the new module:

 

1. Handling for domestic (by method) and international (flat for all methods) is working

2. Module is communicating via RateV4 & IntlRateV2 Syntax

3. Transit time responses are coming through, but still need work.

4. USPS insurance rates are being applied both domestically and internationally.

5. The new syntax requires average package size. The user can define package size in admin panel.

6. The user can define whether to charge retail rates or internet rates (when available).

 

Here's what I'm still working on:

 

1. Somehow, I've completely lost sales tax - that needs to be fixed

2. User will be able to define a processing time and that time will be ADDED to the USPS provided shipping time - so your customers will see a more realistic delivery estimate.

3. Options to display transit time, insurance, and weights - controlled separately.

4. Add user defined insurance - choose between user defined or USPS (or the higher of the two if I can get that to work).

5. Display pop up or link or terms of acknowledgement, blah blah, to international prohibited items list.

6. Fix the trademark legends so that they display properly without interfering with functions - yes this is mandatory.

 

I make no promises that everything will come together as planned. But, so far so good - and it appears to be working for my "white screen" friend, Debbie, too. :thumbsup:

Link to comment
Share on other sites

Looks like the new USPS Methods 5.0.3 blew up my order editor. I get this message when clicking on "Edit" for an invoice:

 

Fatal error: Call to undefined function: tep_round_up() in D:\home\xxxx\xxxx\oscommerce2\catalog\includes\modules\shipping\usps.php on line 141

Can someone help me get my invoice editor back online (order_editor_5_0_61)?

OK - just a note to you developers on the next addition of USPS Methods. I believe I figured out what was going on with my order editor (a blind squirrel, etc., etc.). Apparently, the order editor loads the "general.php" file under /catalog/admnin/includes/functions instead of the "general.php" file under /catalog/includes/functions. We edited the latter general.php under USPS Methods 5.0.3 to include the tep_round_up() function, but not the one under the admin/includes/functions path.

 

So, I added the tep_round_up() function to the general.php file under the admin's functions folder and now my order editor works again without the fatal error.

Edited by TomB01
Link to comment
Share on other sites

OK - just a note to you developers on the next addition of USPS Methods. I believe I figured out what was going on with my order editor (a blind squirrel, etc., etc.). Apparently, the order editor loads the "general.php" file under /catalog/admnin/includes/functions instead of the "general.php" file under /catalog/includes/functions. We edited the latter general.php under USPS Methods 5.0.3 to include the tep_round_up() function, but not the one under the admin/includes/functions path.

 

So, I added the tep_round_up() function to the general.php file under the admin's functions folder and now my order editor works again without the fatal error.

 

Ya know.. I do belive I have the rounding call in both.. let me check.. yes indeed, it is in both.. I will adjust the readme now and upload.. OK adjusted and that gave me the opportunity to correct a slew of typos -- hahaha my motto is "if there are no typos, I didn't do it!"

 

In catalog/admin/includes/functions/general.php
FIND:

// Calculates Tax rounding the result
 function tep_calculate_tax($price, $tax) {
   return $price * $tax / 100;
 }

ADD AFTER:

////
// Round up function for non whole numbers by GREG DEETH
// The value for the precision variable determines how many digits after the decimal and rounds the last digit up to the next value
// Precision = 0 -> xx.xxxx = x+
// Precision = 1 -> xx.xxxx = xx.+
// Precision = 2 -> xx.xxxx = xx.x+
 function tep_round_up($number, $precision) {
$number_whole = '';
$num_left_dec = 0;
$num_right_dec = 0;
$num_digits = strlen($number);
$number_out = '';
$i = 0;
while ($i + 1 <= strlen($number))
{
	$current_digit = substr($number, $i, ($i + 1) - $num_digits);
	if ($current_digit == '.') {
		$i = $num_digits + 1;
		$num_left_dec = strlen($number_whole);
		$num_right_dec = ($num_left_dec + 1) - $num_digits;
	} else {
		$number_whole = $number_whole . $current_digit;
		$i = $i + 1;
	}
}
if ($num_digits > 3 && $precision < ($num_digits - $num_left_dec - 1) && $precision >= 0) {
	$i = $precision;
	$addable = 1;
	while ($i > 0) {
		$addable = $addable * .1;
		$i = $i - 1;
	} 
	$number_out = substr($number, 0, $num_right_dec + $precision) + $addable;
} else {
	$number_out = $number;
}
return $number_out;
 }

Edited by wkdwich

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

Could you please add the actual general.php and modules.php files in the next update? I would like to use a file comparison program to try to figure out how to modify the files. I tried editing from the text instructions and I got rounding errors that wouldn't allow me to sign in under admin or visit my store. My store has many add-ons and some of the edits didn't work as I couldn't find the specific locations. I am coming from version USPS XML API V3 that stopped working in the past day, so my site is down for shipping. It is hobbling now with very limited shipping. Also, could you please provide better instuctions how to modify the database? I couldn't figure out how to make the couple of small changes. Where is set_function in the configuration table?? I can't find it.

Link to comment
Share on other sites

I've installed the latest updates and now I'm getting some interesting output. I'm thinking that the MODULE_SHIPPING_USPS_TEXT_ESTIMATED and MODULE_SHIPPING_USPS_TEXT_DAYS constants aren't being set somewhere?

 

Does anyone have it installed properly so that I can know what to set the constants to? For now I'll probably just add a couple of lines in /catalog/checkout_shipping.php and set them to "About" and "days"...

 

Shipping Method

This is currently the only shipping method available to use on this order.

United States Postal Service (1 x 0.6lbs) (0lbs, 9.6oz)

First-Class Mail (MODULE_SHIPPING_USPS_TEXT_ESTIMATED 1 - 5 MODULE_SHIPPING_USPS_TEXT_DAYS) $4.75

Parcel Post (MODULE_SHIPPING_USPS_TEXT_ESTIMATED 2 - 9 MODULE_SHIPPING_USPS_TEXT_DAYS) $6.90

Priority Mail (MODULE_SHIPPING_USPS_TEXT_ESTIMATED 1 - 3 MODULE_SHIPPING_USPS_TEXT_DAYS) $7.10

Express Mail (MODULE_SHIPPING_USPS_TEXT_ESTIMATED 1 - 2 MODULE_SHIPPING_USPS_TEXT_DAYS) $17.25

Add Comments About Your Order

Link to comment
Share on other sites

Could you please add the actual general.php and modules.php files in the next update? I would like to use a file comparison program to try to figure out how to modify the files. I tried editing from the text instructions and I got rounding errors that wouldn't allow me to sign in under admin or visit my store. My store has many add-ons and some of the edits didn't work as I couldn't find the specific locations. I am coming from version USPS XML API V3 that stopped working in the past day, so my site is down for shipping. It is hobbling now with very limited shipping. Also, could you please provide better instuctions how to modify the database? I couldn't figure out how to make the couple of small changes. Where is set_function in the configuration table?? I can't find it.

 

 

While I would like to do that, right now I can not.. I do not use vanilla osc, but oscMAX and that is highly modified, so my version is going to differ greatly. When Jetta gets further along I will grab the latest osc version and do that yes, sorry but for now I just cant.

 

Phpmyadmin

configuration table --> structure

edit set_function from 255 to 1020

 

 

but running the statement imcluded in the latest README should do it

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

I've installed the latest updates and now I'm getting some interesting output. I'm thinking that the MODULE_SHIPPING_USPS_TEXT_ESTIMATED and MODULE_SHIPPING_USPS_TEXT_DAYS constants aren't being set somewhere?

 

 

Starland, you did not load the language file

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

My newest module is not working with paypal express in one page checkout. I am further along than the contributions. But, I'm not sure at what point it stopped working. Please test PayPal express before you rely on the latest contribs. Also, I'm not sure if it affects regular checkout as well, or just one page checkout. My guess is that it affects both and the problem lies with communicating with Paypal in general. I must have removed something that I shouldn't have.

 

For anyone interested in seeing the changes I'm making and the progress, or anyone interested in testing it at different phases, here is a link to the work in progress:

 

http://www.fulluvscents.com/uspstestfiles/index.htm

 

If someone can pinpoint when Paypal stopped working or when sales tax was lost, it would be greatly appreciated.

 

By the way, I am not a coder or a developer. I'm just a osCommerce website owner who wants things to be a certain way. In my quest for perfection, if I can help others improve their websites, then that's okay too. I make no promises.

Link to comment
Share on other sites

Just curious why you don't use oscMAX forum fix for this problem.

 

While I would like to do that, right now I can not.. I do not use vanilla osc, but oscMAX and that is highly modified, so my version is going to differ greatly. When Jetta gets further along I will grab the latest osc version and do that yes, sorry but for now I just cant.

 

Phpmyadmin

configuration table --> structure

edit set_function from 255 to 1020

 

 

but running the statement imcluded in the latest README should do it

Link to comment
Share on other sites

i have used USPS methods for years.....im building a new store osc ver 2.3.1......installing the latest version of USPS methods with the new readme file.......and everything looks fine after install in admin panel, but after i enter all the fields in admin and click save, all the fields either say array, 0 or nothing........

Edited by robus
Link to comment
Share on other sites

Just curious why you don't use oscMAX forum fix for this problem.

 

Because we use this module.. many of the modules installed into MAX are the very same ones you use here, they just have been pre-added. Then I added seversl more myself.

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

i have used USPS methods for years.....im building a new store osc ver 2.3.1......installing the latest version of USPS methods with the new readme file.......and everything looks fine after install in admin panel, but after i enter all the fields in admin and click save, all the fields either say array, 0 or nothing........

 

 

robus, have you double checked your files changes and uploaded everything to the proper places?

 

Files to upload:

catalog\includes\modules\shipping\usps.php

catalog\includes\languages\english\modules\shipping\usps.php

 

Files to modify:

catalog/includes/functions/general.php

catalog/admin/includes/functions/general.php

catalog/admin/modules.php (only much older versions will need this)

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

i have used USPS methods for years.....im building a new store osc ver 2.3.1......installing the latest version of USPS methods with the new readme file.......and everything looks fine after install in admin panel, but after i enter all the fields in admin and click save, all the fields either say array, 0 or nothing........

 

This is a rehash of the version 4.3.2 and is being updated a step at a time. Unfortunately, it is not complete, and a truly complete package hasn't been uploaded. Mostly, it's a fix to the new problems, and some updates to start compliance with the new USPS rate changes. If you have the changes to your function/general files done and if you have the usps.php and language files uploaded, then go back to 4.3.2 and see if there is anything in those install files that hasn't been touched on.

Link to comment
Share on other sites

robus, have you double checked your files changes and uploaded everything to the proper places?

 

Files to upload:

catalog\includes\modules\shipping\usps.php

catalog\includes\languages\english\modules\shipping\usps.php

 

Files to modify:

catalog/includes/functions/general.php

catalog/admin/includes/functions/general.php

catalog/admin/modules.php (only much older versions will need this)

 

 

i needed to add the last file for older versions for my edited fields to stay filled out....didn't think i would need to since i was working on a fresh install of 2.3.1 and the latest USPS Methods.......now everything ALMOST works........now i get not normal text on the chose shipping methods page........

 

United States Postal Service (1 x 1lbs) (1lbs, 0oz) United States Postal Service

Priority Mail (MODULE_SHIPPING_USPS_TEXT_ESTIMATED 1 - 3 MODULE_SHIPPING_USPS_TEXT_DAYS) $7.65

Express Mail (MODULE_SHIPPING_USPS_TEXT_ESTIMATED 1 - 2 MODULE_SHIPPING_USPS_TEXT_DAYS) $17.80

 

any ideas?

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