Post by sitedzine » Fri Jan 14, 2011 4:07 am

Hello,

I have a client that ships small items, and ever since the USPS changed their rates and methods on the 2nd, he has been getting hammered with people choosing First-Class Postcards as a shipping method--kind of hard to stick products "in" a postcard. This seems to be the method the USPS serves for orders under 3.5 oz. The current module (that worked with the old USPS API) does have checkboxes to include/exclude certain shipping options, but these no longer work.

Has anyone else run into this? If so, have you found a fix for it or is there a fix from the devs in the works?

Thanks,

Jon

Newbie

Posts

Joined
Sat Jul 31, 2010 12:30 am

Post by Qphoria » Fri Jan 14, 2011 4:54 am

Yea. i have to look at this

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by sitedzine » Fri Jan 14, 2011 5:59 am

Good deal. Thanks for looking into this Q.

Newbie

Posts

Joined
Sat Jul 31, 2010 12:30 am

Post by sitedzine » Sun Jan 23, 2011 4:21 am

I was wondering if anyone has found a fix for this yet. One of my clients is (im)patiently waiting as his customers continue to pay $0.28 for shipping that actually costs him quite a bit more.

Newbie

Posts

Joined
Sat Jul 31, 2010 12:30 am

Post by Old Ken » Sat Jan 29, 2011 9:10 am

Hi This is Old Ken,
I'm having the same problem. I went to the post office and they classified my 6in by 9in bubble wrap envelope as a "small parcel" and for 3 onces the rate should be $1.56 and not $0.28 as my shopping cart shows. There is no "small parcel" option available in the menu.
But I'm sorry that I can't offer a solution. I'm strictly a user not a programmer.

Newbie

Posts

Joined
Fri Jul 16, 2010 4:56 am

Post by sitedzine » Tue Feb 15, 2011 10:00 am

Has the USPS module been fixed or has anyone created a fix/patch for it yet?

Newbie

Posts

Joined
Sat Jul 31, 2010 12:30 am

Post by TalonRAge » Thu Mar 03, 2011 10:59 pm

Found the cause of this problem but don't have time to fix and test this morning.

Cause:
1. shippingapis.com retruns RateV3Response with multiple <Postage CLASSID="0"> tags last of which is postcard postage
2. catalog/model/shipping/usps.php has a foreach loop on CLASSID, since there are multiple it overwrites until the last is finally in there hence the postcard becoming our price.

Other notes:
Under the Postage tag there is a MailService tag that has the name "First-Class Mail<sup>&reg;</sup> Package" I do believe is the everyone wants and it comes first.

Sorry this isn't a fix yet, If someone else can find a proper one without breaking anything else before I return this evening cool if not I will hopefully find one then.

"Design, Develop, and have fun."
http://www.chrislockard.com

OC: v1.4.9.5


User avatar
Newbie

Posts

Joined
Tue Feb 01, 2011 12:11 am
Location - California, USA

Post by TalonRAge » Fri Mar 04, 2011 4:16 pm

Well I believe I have this one licked but would like others to let me know if it took care of the issue for them as well.

This fix was created on OpenCart 1.4.9 and also had Qphoria's fix for the garbled code found here:
http://forum.opencart.com/viewtopic.php ... 28#p123964

make the following change to the catalog/model/shipping/usps.php file
find:

Code: Select all

$quote_data[$classid] = array(
	'id'           => 'usps.' . $classid,
	'title'        => $postage->getElementsByTagName('MailService')->item(0)->nodeValue,
	'cost'         => $this->currency->convert($cost, 'USD', $this->currency->getCode()),
	//'tax_class_id' => 0,
	'tax_class_id' => $this->config->get('usps_tax_class_id'),
	'text'         => $this->currency->format($this->tax->calculate($this->currency->convert($cost, 'USD', $this->currency->getCode()), $this->config->get('usps_tax_class_id'), $this->config->get('config_tax')))
);
and replace with

Code: Select all

$ms = $postage->getElementsByTagName('MailService')->item(0)->nodeValue;
if($classid == 0 && $ms == 'First-Class Mail Package'){
	$quote_data[$classid] = array(
		'id'           => 'usps.' . $classid,
		'title'        => $postage->getElementsByTagName('MailService')->item(0)->nodeValue,
		'cost'         => $this->currency->convert($cost, 'USD', $this->currency->getCode()),
		//'tax_class_id' => 0,
		'tax_class_id' => $this->config->get('usps_tax_class_id'),
		'text'         => $this->currency->format($this->tax->calculate($this->currency->convert($cost, 'USD', $this->currency->getCode()), $this->config->get('usps_tax_class_id'), $this->config->get('config_tax')))
	);
}
if($classid != 0){
	$quote_data[$classid] = array(
		'id'           => 'usps.' . $classid,
		'title'        => $postage->getElementsByTagName('MailService')->item(0)->nodeValue,
		'cost'         => $this->currency->convert($cost, 'USD', $this->currency->getCode()),
		//'tax_class_id' => 0,
		'tax_class_id' => $this->config->get('usps_tax_class_id'),
		'text'         => $this->currency->format($this->tax->calculate($this->currency->convert($cost, 'USD', $this->currency->getCode()), $this->config->get('usps_tax_class_id'), $this->config->get('config_tax')))
	);
}
If you did not fix the garbled code using Qphoria's update above you may want to replace the "First-Class Mail Package" with the following bit "First-Class Mail<sup>&reg;</sup> Package"

This should fix it to where you are no longer having Postcards show up for your first class shipping.

I am also adding a vQmod that does this for those who are using it.

Attachments


"Design, Develop, and have fun."
http://www.chrislockard.com

OC: v1.4.9.5


User avatar
Newbie

Posts

Joined
Tue Feb 01, 2011 12:11 am
Location - California, USA

Post by ksawatzk » Tue Mar 08, 2011 9:57 am

Sorry TalonRAge, I just tried your change but still have "First-Class Mail Postcards" showing up.

I appreciated the link to Qphoria's fix for the garbled code, that was the next thing I was going to look for. Got that fixed anyway.

(Yes, I did apply your change to his usps.php file)

Newbie

Posts

Joined
Fri Jan 07, 2011 12:24 am

Post by TalonRAge » Tue Mar 08, 2011 10:31 am

Just wanted to let you know I happened to be browsing through the forums as you had entered this and am looking at it in a few different ways to see if I can replicate what you are seeing.

**Edit**
Sent you a PM regarding this.

"Design, Develop, and have fun."
http://www.chrislockard.com

OC: v1.4.9.5


User avatar
Newbie

Posts

Joined
Tue Feb 01, 2011 12:11 am
Location - California, USA

Post by MeanGuns » Wed Mar 16, 2011 1:46 am

I have been having a problem with 1.4.9.3 also. I fixed the garbled code in the checkout and the fix works fine. The problem I am having is that the USPS first class mail option does not show up as an option for checkout even though the weight is below 13oz. If it was the only thing selected in the admin it won't show up at all. I don't get the USPS postcard option but don't need that one. USPS First Class is the cheapest way to sent the packages I have and it does not work at all. does anyone know how to fix this in 1.4.9.3 any help would be appreciated.

Mean :choke:

Newbie

Posts

Joined
Sat Nov 14, 2009 2:38 am

Post by TalonRAge » Wed Mar 16, 2011 10:19 pm

If you do the following you will get some logging on what is being sent out and what is getting returned when you make your shipping rate quote request.

To see what you are sending.
find:

Code: Select all

					$request = 'API=IntlRate&XML=' . urlencode($xml);
				} else {
					$status = FALSE;	
				}
			}	
			
			if ($status) {
				$ch = curl_init();
replace with:

Code: Select all

					$request = 'API=IntlRate&XML=' . urlencode($xml);
				} else {
					$status = FALSE;	
				}
			}	
			$this->log->write($xml);
			
			if ($status) {
				$ch = curl_init();
To see what you are receiving.
find:

Code: Select all

				if ($result) {
					$dom = new DOMDocument('1.0', 'UTF-8');
					$dom->loadXml($result);	
replace with:

Code: Select all

				$this->log->write($result);
				if ($result) {
					$dom = new DOMDocument('1.0', 'UTF-8');
					$dom->loadXml($result);	
All you are doing is adding the log writing function to the xml you are sending and receiving and it is being place in you logs to view. You will find that in the Administration under System>Error Logs.

"Design, Develop, and have fun."
http://www.chrislockard.com

OC: v1.4.9.5


User avatar
Newbie

Posts

Joined
Tue Feb 01, 2011 12:11 am
Location - California, USA

Post by MeanGuns » Wed Mar 16, 2011 11:03 pm

I think it's just broken. First class does not work with a fresh install of opencart 1.4.9.3 to the server it does not even give you an option for fist class even though the item is below 13oz. The US postal service must have changed something or it just never worked in this version. Other options do work like express mail and priority mail packages and boxes but first class mail is defunct. So the code above won't see what is not being sent or replied to because The USPS is not sending data back or Open cart is not sending data out. The fact is it is definatly broken, how can I be sure? I tried wo diffrent servers hosting 1.4.9.3 and they were fresh installs of opencart everything else works except First Class mail and First class post cards. So I assume the USPS must have changed their code in some way.

Newbie

Posts

Joined
Sat Nov 14, 2009 2:38 am

Post by Qphoria » Wed Mar 16, 2011 11:37 pm

It wont work with a fresh install because the usps change happened on Jan 2nd 2011..
there is a patch for part of it. The remaining aspect is the postcard issue. I am looking at that for 1.4.9.4

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by MeanGuns » Thu Mar 17, 2011 10:30 am

Can you post the fix for USPS first class mail or post the link so those of us having trouble getting it to work in 1.4.9.3 can patch or fix our stores?

Thanks Q

Mean

Newbie

Posts

Joined
Sat Nov 14, 2009 2:38 am

Post by dare2stnd » Tue Apr 05, 2011 6:53 pm

Thanks to Talon for that code change. That worked perfectly and i had a fresh install of the latest version. The code was still the old code for some reason in the USPS file. Once i changed it it fixed the First class issue so now i get First Class Mail package and the right rate as well.

also just a note for people who had or have issues getting the dumb usps module to work. I had to change my box size from rectangular to Variable before it would even start quoting rates for me.

Newbie

Posts

Joined
Tue Apr 05, 2011 6:49 pm

Post by sitedzine » Thu Apr 07, 2011 5:11 am

Awesome! Thanks so much TalonRAge! Installed on v1.4.9.1 along with Qphoria's garbled code fix, and all appears to work as it should. No more First Class Postcards!

Newbie

Posts

Joined
Sat Jul 31, 2010 12:30 am
Who is online

Users browsing this forum: No registered users and 5 guests