Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Items less then 1 ounce for USPS shipping

Items less then 1 ounce for USPS shipping

Locked

Views: 3,019

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
11 Apr 2009, 1:54 AM
#1
wicks avatar

wicks

New Zenner

Join Date:
Apr 2009
Posts:
13
Plugin Contributions:
0

Items less then 1 ounce for USPS shipping

I see this code:

// usps doesnt accept zero weight

$usps_shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);

$shipping_pounds = floor ($usps_shipping_weight);

$shipping_ounces = round(16 * ($usps_shipping_weight - floor($usps_shipping_weight)));

If I wanted to make the ounces round up to the 10th of an ounce or less would I just change the 16 to or would I change the shipping weight to read < 1 ? 1 :

I have seriously tried to change the code to < 1 ? 1 : and it then says that for USPS to ship first class mail it has to weigh under 13 ounces. All of my inventory weighs under an ounce. Most of it weighs 0.000568091 and .0625. How do I get the shipping correct? (I only need first class shipping.)

11 Apr 2009, 5:07 AM
#2
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Items less then 1 ounce for USPS shipping

the shipping weight is in pounds - so your <1 ? 1: edit results in anything less than 1 pound being set to 1 pound. The original $usps_shipping_weight line makes anything less than 0.1 pounds equal to 0.1 pounds - that is then converted to ounces in the $shipping_ounces line, which would make your absolute minimum weight for submission to USPS equal 1.6 ounces.
You could change all that code to this to ensure that the minimum weight submitted is 1 ounce.

Edit: oops - clicked the wrong button and submitted before I finished...will post suggested code in a few minutes....

11 Apr 2009, 5:23 AM
#3
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Items less then 1 ounce for USPS shipping

You could change all that code to this to ensure that the minimum weight submitted is 1 ounce, and ounces are submitted to one decimal place (which the USPS API accepts):

  $shipping_pounds = floor ($shipping_weight);
  $shipping_ounces = number_format(16 * ($shipping_weight - floor(shipping_weight )), 1);
  if ($shipping_pounds == 0 and $shipping_ounces < 1) $shipping_ounces = 1;