Post by matt6805 » Sat Dec 05, 2009 2:32 am

I'm having an issue with the USPS module. When I ship something that weights just a touch over a pound Priority mail, the module returns a value of $12.40. I'm shipping it to my home town, so it's as close as possible. I called USPS and they said that's way to high. It should be around 4 dollars.

When i adjust the weight of a product in the admin section to 1 ounce, the price shows as correct $4.95 cents. What could account for the weight measurements being so off? I'm running OpenCart v1.3.4. Has anyone else seen this issue? ???

Regards,
Matt

Newbie

Posts

Joined
Fri Nov 13, 2009 2:31 am

Post by Daniel » Sat Dec 05, 2009 4:23 am

check your weight classes.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by matt6805 » Tue Dec 08, 2009 12:00 am

Thanks for the reply Daniel. My weight classes are the default that come with OpenCart. I haven't touched them. All products are set to use ounces, so I'm not sure why the rate is so high.

I've left the dimensions and the girth fields in the USPS shipping module blank. Do you suppose that would be the reason for the high shipping?

Regards,
Matt

Newbie

Posts

Joined
Fri Nov 13, 2009 2:31 am

Post by Qphoria » Tue Dec 08, 2009 12:18 am

The weight calculation is bugged.

Code: Select all

$weight = $this->cart->getWeight();
			
$weight = ($weight < 0.1 ? 0.1 : $weight);
$pounds = floor($weight);
$ounces = round(16 * ($weight - floor($weight)));
The way this reads, if you have a product set 16oz, that should be 1lb
But the code assumes lbs is the default weight. So it is making 16lbs.
It needs to do a weight conversion to lbs first, then do the floor & round calls.

1. EDIT: catalog/model/shipping/usps.php

2. FIND:

Code: Select all

$weight = $this->cart->getWeight();
3. REPLACE WITH:

Code: Select all

$lb = $this->db->query("SELECT DISTINCT weight_class_id FROM " . DB_PREFIX . "weight_class WHERE unit = 'lb'");
$weight = $this->weight->convert($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $lb->row['weight_class_id']);

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by matt6805 » Tue Dec 08, 2009 3:46 am

You have just fixed days of frustration. Thank you so much! Love the cart, can't wait till more people contribute to it and the community grows.

Regards,
Matt

Newbie

Posts

Joined
Fri Nov 13, 2009 2:31 am

Post by JNeuhoff » Thu Dec 31, 2009 2:49 am

The USPS code line

Code: Select all

			$weight = $this->cart->getWeight();
should be replaced with

Code: Select all

			$defaultWeightClassId = $this->config->get('config_weight_class_id');
			$query = $this->db->query("SELECT wc.weight_class_id FROM `".DB_PREFIX."weight_class` wc LEFT JOIN `".DB_PREFIX."language` l ON l.language_id=wc.language_id WHERE l.code='en' AND wc.unit='lb';");
			$poundWeightClassId = $query->row['weight_class_id'];
			$weight = $this->weight->convert($this->cart->getWeight(),$defaultWeightClassId,$poundWeightClassId);
As regards the other 'weight' shipping module: Make sure the weights are specified in the default weight units. The latter was set at Opencart's admin backend at

Admin > Configuration > Setting > Local > Weight Class

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Thu Dec 31, 2009 10:11 am

JNeuhoff wrote:The USPS code line

Code: Select all

			$weight = $this->cart->getWeight();
should be replaced with

Code: Select all

			$defaultWeightClassId = $this->config->get('config_weight_class_id');
			$query = $this->db->query("SELECT wc.weight_class_id FROM `".DB_PREFIX."weight_class` wc LEFT JOIN `".DB_PREFIX."language` l ON l.language_id=wc.language_id WHERE l.code='en' AND wc.unit='lb';");
			$poundWeightClassId = $query->row['weight_class_id'];
			$weight = $this->weight->convert($this->cart->getWeight(),$defaultWeightClassId,$poundWeightClassId);
As regards the other 'weight' shipping module: Make sure the weights are specified in the default weight units. The latter was set at Opencart's admin backend at

Admin > Configuration > Setting > Local > Weight Class
Didn't I address this above already?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Thu Dec 31, 2009 9:14 pm

Didn't I address this above already?
Yes, except that my SQL query also makes sure that is uses the weight_class_id for the right language as well as the right weight unit.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Fri Jan 01, 2010 8:27 am

I see.... tho is it likely that an english "lb" would be different than the value of a spanish "lb"? There really is no way to have a separate language for lb as that is the code and languages are dependencies of the code, not the code dependent on the language.

the "lb" is the deciding factor.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by flyfishingcolorado » Sat Jan 02, 2010 12:10 am

I have adjusted the code Juergen has suggested. That fixed some of the error that I was getting. Now I get
Notice: Undefined variable: shipping_address in catalog/model/shipping/usps.php on line 358
Notice: Undefined index: IntlRateResponse in catalog/model/shipping/usps.php on line 373

I know my usps user and password are working on the USPS production server because I have tested them in another shopping cart script test.

Any ideas on this.

Any help would be appreciated


Posts

Joined
Sun Nov 29, 2009 5:04 pm

Post by JNeuhoff » Sat Jan 02, 2010 1:08 am

I think the line near 358:

Code: Select all

					if ($shipping_address['iso_code_2'] == 'US') { 
should be replaced with:

Code: Select all

					if ($country_info['iso_code_2'] == 'US') {
The other error should then disappear, too. Looks like this shipping module wasn't well tested. But we are getting there :)

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by flyfishingcolorado » Sat Jan 02, 2010 4:07 am

1/1/10

Thanks Juergen, This fixed the errors and my choices selected on the USPS extension setup show up just fine in cart checkout.

Now everything for USPS is controlled by the individual product data setup which is as it should be.

To all who may read this reply. You do need to use the dimensions in each product data setup. I suggest using the dimensions of the normal shipping container you will use to ship the product. Also the weight should be the shipping weight.

Finally when J. Nuehoff speaks on Open Cart, pay attention. He knows this product. Same goes for Qphoria.


Posts

Joined
Sun Nov 29, 2009 5:04 pm

Post by Qphoria » Sat Jan 02, 2010 8:22 am

JNeuhoff wrote:I think the line near 358:

Code: Select all

					if ($shipping_address['iso_code_2'] == 'US') { 
should be replaced with:

Code: Select all

					if ($country_info['iso_code_2'] == 'US') {
The other error should then disappear, too. Looks like this shipping module wasn't well tested. But we are getting there :)
All the usps bugs with php errors were fixed here:
http://forum.opencart.com/viewtopic.php ... sps#p39586
it does not, however, include the getweight fix to use only products that have required shipping set.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by flyfishingcolorado » Sat Jan 02, 2010 9:47 pm

This is a general observation.
If you are using PayPal as the payment module, PayPal forces you to use their shipping calculations even if you think every shipping method you set up on PayPal is inactive.

Unfortunately OpenCart does not allow us to disable the shipping methods when using PayPal for payment.

I tested this 1/2 with extensive transactions on the live paypal server and everytime Paypal would add their shipping to my USPS calculated shipping.


Posts

Joined
Sun Nov 29, 2009 5:04 pm

Post by flyfishingcolorado » Sat Jan 02, 2010 9:51 pm

read my reply about using PayPal and USPS rates to high in the usps thread.

OpenCart needs to allow us to turn off all shipping modules when using PayPal as a payment method. PayPal forces you to use their shipping calculations even if you think they are inactive. I know because I tested 10 transactions tonight to confirm that shipping will be added to the total of the Open Cart amount which already includes shipping.


Posts

Joined
Sun Nov 29, 2009 5:04 pm

Post by Qphoria » Sat Jan 02, 2010 10:01 pm

flyfishingcolorado wrote: OpenCart needs to allow us to turn off all shipping modules when using PayPal as a payment method. PayPal forces you to use their shipping calculations even if you think they are inactive. I know because I tested 10 transactions tonight to confirm that shipping will be added to the total of the Open Cart amount which already includes shipping.
I sell all digital downloads on my site and have require shipping off.. when people checkout with paypal there is no forced shipping. You must have some other settings set on your paypal account. There is no code in the paypal module that is forcing paypal shipping rates

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 4 guests