Problem/Motivation

When trying to add a Shipping method after configuring a package type that has an empty weight (e.g 0g), I got a PluginException ("The package type "commerce_package_type"... property "weight" must have a "number" key.)

I debugged it, and it seems to be due to the empty() check performed in the PackageTypeManager class.

      foreach (['number', 'unit'] as $weight_property) {
        if (empty($definition['weight'][$weight_property])) {
        }
     }

Proposed resolution

Replace the empty() call by !isset().

Remaining tasks

Propose a patch.

Comments

jsacksick created an issue. See original summary.

jsacksick’s picture

Status: Active » Needs review
StatusFileSize
new659 bytes
jsacksick’s picture

Title: PluginException when trying to add a Shipping method that has a weight set to 0. » PluginException when trying to add a Shipping method after adding a package type that has a weight set to 0.
jsacksick’s picture

Title: PluginException when trying to add a Shipping method after adding a package type that has a weight set to 0. » PluginException when trying to add a Shipping method after adding a package type that has an empty weight

  • bojanz committed b88f131 on 8.x-2.x authored by jsacksick
    Issue #2843602 by jsacksick: PluginException when trying to add a...
bojanz’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.