verbb / postie

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

UPS: Product Dimensions #81

Closed clarknelson closed 2 years ago

clarknelson commented 2 years ago

Description After installing the plugin in the list of products that need dimensions, there are a few products that I wouldn't expect need dimensions.

Screenshot from 2021-12-13 15-26-02

Clubs and events do not have dimensions, and while equipment does have weight and dimensions, none are set right now.

Although only 20 products are shown as needing dimensions when there are a lot more, is it capped to this number? Previously I have set all 20 product dimensions and it doesn't seem to check again more need to be set.

Steps to reproduce

  1. Have existing products, some requiring dimensions and some do not.
  2. Have more than 20 products requiring dimensions to be set.
  3. Install plugin

Additional info

clarknelson commented 2 years ago

Screenshot from 2021-12-14 18-31-14

"UPS: API error: “Failure: Missing/Illegal Combination of Package/Dimensions (110602)” /app/vendor/gabrielbull/ups-api/src/Request.php:145"

When I try to authorize the UPS API I get this error message. I'm going to work on a method to set the weight and dimensions for all my products so hopefully this is not an issue going forward.

clarknelson commented 2 years ago

I did set the weight and dimensions for all of our products that require those attributes but I have the same error as before. There are a few product types (classes, clubs, etc) that we do not ship. Those don't have weight and dimensions variables enabled in Craft, but one of each shows up in the Products tab (see screenshot above).

Maybe there is a bug related to that functionality? It may be a good place to start. I don't really see why I am unable to even authenticate with the UPS API without the package dimensions. Seems more of a runtime error depending on what products are in the cart.

engram-design commented 2 years ago

I've fixed the product in the product type with Show the Dimensions and Weight fields for products of this type unticked. As you say, they shouldn't be included.

As for the 20 limit, that's indeed the set limit, as some stores have thousands of variants, which can really affect the performance of this. However, thanks to query batching is the last few versions of Craft, we can make this better (with some caveats).

Should be fixed for the next version.

But you can also modify this query using the modifyVariantQuery event.

As for the actual issue with UPS, can you comment on the region the UPS account is for? If it's for the US, ensure your units are imperial, but for the rest of the world it should be metric - whatever your UPS is configured to. It doesn't matter what your Commerce store is configured to, as Postie will convert them for you, but the UPS provider settings need to be configure according to the UPS account's region.

The reason I state this is due to the fact that testing the connection throws an error - where we actually create a test box to send to UPS.

However, I think what might be happening is some lack precision-checking when converting units - as that was the only way I could replicate it. To get the fix early, change your verbb/postie requirement in composer.json to:

"require": {
  "verbb/postie": "dev-craft-3 as 2.4.14",
  "...": "..."
}

Then run composer update.

clarknelson commented 2 years ago

I'm not sure what you did but I updated composer and everything works! The message for products without weight / dimensions disappeared. And the UPS API authenticated. I am able to see shipping rates on my cart

Screenshot from 2021-12-21 11-55-25

Thank you so much for your help with this so quickly. Have a happy holidays