verbb / postie

A Craft Commerce shipping calculator plugin.
Other
12 stars 18 forks source link

Multiple Boxes in USPS #59

Closed johnj24 closed 3 years ago

johnj24 commented 3 years ago

Description Hey, Josh. I'm setting up a store that carries just t-shirts and hats. I want to keep shipping simple, so I've only activated First Class Large Envelope and First Class International within USPS. It's my understanding that USPS allows those shipping methods to weigh 1lb, otherwise you have to move up to Priority Mail or just ship it in two separate envelopes. I'm hoping I can just ship within two envelopes if an order does exceed 1lb.

I've set up a multi-box packing method with the settings in this screenshot. However, once I get to a certain amount of items in my cart, no shipping methods show up and no error messages are given on the front-end.

Screen Shot 2021-02-19 at 12 39 11 PM

Here is postie.log

2021-02-19 13:20:52 [-][834356][-][info][postie] USPS: Domestic rate service call
2021-02-19 13:20:52 [-][834356][-][info][postie] USPS: Sending payload: `{}`.
2021-02-19 13:20:51 [-][834356][-][info][application] $_GET = [
    'p' => 'shop/checkout/address'
]

My assumption is I've gone over either the weight limit or the dimensions are now exceeding my box. But isn't this where the multi-box packing method comes in and splits the order into multiple boxes?

The confusing part is I've given dimensions to a fairly big polymailer in the packing method and I've decreased my shirt dimensions down to basically nothing (below). Even then apparently two t-shirts are too big for the polymailer (this is of course not true in reality). I've messed with the Height dimension and gone from 25mm to 12mm and I was able to get a second shirt in the cart with a shipping method. Once I added a third shirt, the methods disappeared again.

Shirt Sizes Dimensions: 25mm / 25mm / 25mm Weight: 110g (the weight increases 10 grams for each size up)

Steps to reproduce

  1. Enable USPS
  2. Enable USPS First Class Mail Large Envelope and First Class Mail International
  3. Set up multi-box packing in USPS with the specs in the screenshot
  4. Set up t-shirt products with the sizes above.
  5. Add multiple shirts to the cart and try to choose a shipping method

Additional info

Additional context

engram-design commented 3 years ago

Appreciate the comprehensive report! So from my testing domestic seems to be returning correctly, but not international. It looks like the box-packing is correct, and that 4 items (of your specification) can fit in a single box, pushing to 5 adds a new box.

Can you confirm if you're testing domestic, international, or both? I believe for domestic, we don't actually factor in dimensions, just weight.

Just for clarity, here are my results for your same setup, with 2 shirts in the cart. I've also enabled all shipping methods, just to remove that as a factor.

Domestic (US to US) image

International (US to Canada) image

In the process, I've actually found an issue with USPS and reporting pricing incorrectly (often not at all) when there's multiple boxes involved, which might be what's going on here. Are you able to give the 2.4.7 version a go with this fix?

Although what's main concerning is the lack of First Class Mail International even on my latest testing.

johnj24 commented 3 years ago

Josh, I've updated to 2.4.7 but everything still feels a bit wonky. With the specs I've provided, I can get 6 shirts in the cart with a First Class Large Envelope showing, but adding a 7th shirt returns no shipping method. Adding an 8th shirt returns a shipping method, but a 9th shirt doesn't return anything again. Here's how the pricing is being sent back from USPS based on the cart quantity:

1 shirt: 3.60 2 shirts: 2.80 3 shirts: 3.60 4 shirts: 6.20 5 shirts: 6.20 6 shirts: 3.60 7 shirts: no available shipping method 8 shirts: 3.60 9 shirts: no available shipping method 10 shirts: no available shipping method

This was all tested with the same shirt variant using these specs: 25mm / 25mm / 25mm; 120g

The only enabled shipping methods are First Class Large Envelope and First Class International. Let me know if you need store and destination locations.

I also have a separate hat product that gives me no available shipping method after only 2 or 3 shirts are added with it (need to test more thoroughly). My gut is telling me that the Postie software is still not taking into account multiple boxes, because with multiple boxes there should never be a time when no shipping methods are available if you can use more than one box. Right?

engram-design commented 3 years ago

So I'm seeing similar (not identical) behaviour:

1 - $1.80 2 - $2.60 3 - none 4 - $5.20 5 - $2.60 6 - none 7 - $5.20 8 - $2.60 9 - none 10 - $5.20

The jump in price (from 2-4, 7-8 items) looks to be due to the max weight being hit, and one of the parcels not having a rate returned.

To illustrate, here's what boxes are being sent for the above:

1 item

Box 1 - 'name' => '10x13 Poly', 'weight' => 0.29, 'width' => 12.99, 'length' => 10, 'height' => 5

2 items

Box 1 - 'name' => '10x13 Poly', 'weight' => 0.56, 'width' => 12.99, 'length' => 10, 'height' => 5

3 items

Box 1 - 'name' => '10x13 Poly', 'weight' => 0.82, 'width' => 12.99, 'length' => 10, 'height' => 5

4 items

Box 1 - 'name' => '10x13 Poly', 'weight' => 0.56, 'width' => 12.99, 'length' => 10, 'height' => 5
Box 2 - 'name' => '10x13 Poly', 'weight' => 0.56, 'width' => 12.99, 'length' => 10, 'height' => 5

5 items

Box 1 - 'name' => '10x13 Poly', 'weight' => 0.82, 'width' => 12.99, 'length' => 10, 'height' => 5
Box 2 - 'name' => '10x13 Poly', 'weight' => 0.56, 'width' => 12.99, 'length' => 10, 'height' => 5

So what's interesting to note here is that for 3 items, the weight is 0.82, and for 5 items, where the price is lower than 4 items, the weight of the first box is also 0.82. This would be the common factor between the two, as the dimensions don't change, as you're dealing with your own boxes.

This must be triggering USPS's maximum weight for that particular service. From my research, this is 13oz - or 0.8125lbs. You'll notice that the weight is 0.82lbs for the boxes, so that seems to be the answer - your boxes are too heavy. try adjusting your "Max Weight" to 0.8125lb instead of 1lb, which from my testing works correctly.

As for your last comment, that's sort of true, unless a single item fails to fit in one box, then it theoretically can't be packed.

johnj24 commented 3 years ago

Josh, thank you for looking deeper into this. I will change my box max weight and continue to test. I wasn't exactly sure what to put in that Max Weight input in the Box Sizing table so thank you for clarifying. Maybe a tooltip or instruction could be helpful here to describe what the administrator should consider when adding a Max Weight?

Also, where are you finding those box names and values in your code comments? Is that being logged somewhere?

johnj24 commented 3 years ago

I fixed the Max Weight value and just did a quick test adding 1 to 10 shirts with an additional hat to the cart. It's a much better experience now. Thanks again!

engram-design commented 3 years ago

@johnj24 Good to hear, and I'll look at adding a tooltip to clarify each of those columns.

As for those box names/details I'll look at adding that to the logging mechanism, as currently it involves me having to add debug statements to the code, and that might be useful for everyone to be able to see this for their own debugging.

I should note that the max weight and dimensions are really dependant on the individual provider, so depending on which provider you pick means you'll need to check against their limits and be aware of those when creating your own boxes.