Post by OpenCode » Fri Mar 08, 2019 2:43 am

Hi every one
is there a way to allow the First Class Mail to be shown as an option when the package weight is less the 2lb and No only for less 13 oz.

I was looking at the

Code: Select all

			$weight = ($weight < 0.1 ? 0.1 : $weight);
			$pounds = floor($weight);
			$ounces = round(16 * ($weight - $pounds), 2); // max 5 digits
but I don't see a way to fool the weight to return true if the cart weights less the 2lb

Code: Select all

if ($this->cart->getWeight() < 2) {
}
can any one help...

Thank you

New member

Posts

Joined
Fri Jun 07, 2013 9:31 am

Post by paulfeakins » Fri Mar 08, 2019 7:31 pm

Can't you use the built-in weight-based shipping?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Johnathan » Fri Mar 08, 2019 10:16 pm

USPS will only return First-Class rates when the weight passed to it is 13 oz or less. You'll have to adjust the actual weight being sent to them, and make it smaller if the weight is 2 lb or under. For example:

Code: Select all

IN:
/catalog/model/extension/shipping/usps.php

BEFORE:
$postcode = str_replace(' ', '', $address['postcode']);

ADD:
if ($weight < 2 || ($weight == 2 && $ounces == 0)) {
	$weight = 1;
	$ounces = 0;
}

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by OpenCode » Wed Mar 13, 2019 3:32 am

@Johnathan

Thank you, your code works perfectly...

New member

Posts

Joined
Fri Jun 07, 2013 9:31 am
Who is online

Users browsing this forum: OSWorX and 321 guests