verbb / postie

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

Small weight being rounded to 0 #77

Closed davist11 closed 2 years ago

davist11 commented 2 years ago

Description Many of the products of the Commerce site we are building have very small weights. For example, one product I am looking at has a weight of 0.001 lbs. When I add that item to my cart and the boxes get packed to fetch the shipping rates, we are getting this error FedEx: Weight is missing or invalid.

I dove into the plugin a bit and tried to do some dumping to see what was going on. If I add a Craft::dd($packedBox); inside this foreach:

https://github.com/verbb/postie/blob/021efbb87ed18e9b04af74c3f69dd15e4d69dc9f/src/models/PackedBoxes.php#L40-L70

I get this output:

DVDoug\BoxPacker\PackedBox#1
(
    [*:box] => verbb\postie\models\Box#2
    (
        [verbb\postie\models\Box:reference] => 'Single Box'
        [verbb\postie\models\Box:outerWidth] => 0
        [verbb\postie\models\Box:outerLength] => 0
        [verbb\postie\models\Box:outerDepth] => 0
        [verbb\postie\models\Box:emptyWeight] => 0
        [verbb\postie\models\Box:innerWidth] => 0
        [verbb\postie\models\Box:innerLength] => 0
        [verbb\postie\models\Box:innerDepth] => 0
        [verbb\postie\models\Box:maxWeight] => 68038.9
        [verbb\postie\models\Box:type] => ''
        [verbb\postie\models\Box:price] => null
        [yii\base\Model:_errors] => null
        [yii\base\Model:_validators] => null
        [yii\base\Model:_scenario] => 'default'
        [yii\base\Component:_events] => []
        [yii\base\Component:_eventWildcards] => []
        [yii\base\Component:_behaviors] => []
    )
    [*:items] => DVDoug\BoxPacker\PackedItemList#3
    (
        [DVDoug\BoxPacker\PackedItemList:list] => [
            0 => DVDoug\BoxPacker\PackedItem#4
            (
                [*:x] => 0
                [*:y] => 0
                [*:z] => 0
                [*:item] => verbb\postie\models\Item#5
                (
                    [verbb\postie\models\Item:description] => 'Item 323'
                    [verbb\postie\models\Item:width] => 0
                    [verbb\postie\models\Item:length] => 0
                    [verbb\postie\models\Item:depth] => 0
                    [verbb\postie\models\Item:weight] => 0.45359237
                    [verbb\postie\models\Item:keepFlat] => false
                    [yii\base\Model:_errors] => null
                    [yii\base\Model:_validators] => null
                    [yii\base\Model:_scenario] => 'default'
                    [yii\base\Component:_events] => []
                    [yii\base\Component:_eventWildcards] => []
                    [yii\base\Component:_behaviors] => []
                )
                [*:width] => 0
                [*:length] => 0
                [*:depth] => 0
            )
        ]
        [DVDoug\BoxPacker\PackedItemList:weight] => 0
        [DVDoug\BoxPacker\PackedItemList:isSorted] => true
    )
    [*:itemWeight] => null
    [*:volumeUtilisation] => 0
)

So it appears like there is a weight value on the item. But if I do Craft::dd($weight); after the $weight variable is set, the value is 0. If I change the weight of the product to 0.5 lbs, then I correctly get shipping rates. Is there a specific minimum weight that Fedex expects? Let me know if there's any other info I can provide or if you want me to test other values. Thanks in advance!

Steps to reproduce

  1. Add a small weight to a variant 0.001
  2. Add that variant to your cart and checkout
  3. See that no shipping options are available because the weight is 0

Additional info

engram-design commented 2 years ago

Looks like an issue on our end. Should be fixed in 2.4.10

davist11 commented 2 years ago

Awesome, this resolved it. Thanks so much for the quick fix!