verbb / snipcart

A Craft CMS plugin to integrate with Snipcart.
Other
21 stars 9 forks source link

Snipcart webhook fails when "Shippable" lightswitch is toggled off #13

Closed brettburwell closed 4 years ago

brettburwell commented 4 years ago

Describe the bug We have a product in Craft that has the Shippable lightswitch toggled off in the Snipcart Product Details field. Customers are able to successfully purchase the product, but after checkout I'm receiving a "Webhook has failed for your Snipcart account" email from Snipcart.

Searching through the logs brought up the following error:

[error][TypeError] TypeError: Return value of workingconcept\snipcart\models\ProductDetails::isShippable() must be of the type bool, null returned in /server/path/vendor/workingconcept/craft-snipcart/src/models/ProductDetails.php:361

/server/path/vendor/workingconcept/craft-snipcart/src/models/ProductDetails.php(203): workingconcept\snipcart\models\ProductDetails->isShippable(Object(workingconcept\snipcart\models\ProductDetails))

To Reproduce Steps to reproduce the behavior:

  1. Create a new product in Craft and fill out Snipcart Product Details field, leaving the Shippable lightswitch toggled off
  2. Run through full checkout.
  3. Receive "Webhook failed" notification from Snipcart.

Expected behavior No warning email from Snipcart and product inventory successfully reduces.

Sofware

Additional context I don't believe it's related, but it feels worth mentioning that in Snipcart Plugin Settings > Orders the Reduce Item Quantities on Order? lightswitch is toggled on. There aren't any other relevant, interesting, or unusual settings (that I'm aware of!) on the Craft or Snipcart side of things, but if there's any additional info I can pass along let me know.

mattstein commented 4 years ago

Thanks for this, @brettburwell! I'll take a look and get back to you today.

brettburwell commented 4 years ago

Thanks for the quick reply duder!

mattstein commented 4 years ago

@brettburwell Just tagged a new release that should fix this. Would you mind updating to 1.2.4 and giving it a whirl?

Also, thanks for filing a beautiful issue that made it easy to track down. ❤

brettburwell commented 4 years ago

@mattstein Just updated and tested on staging and all looks well. Thanks for such a quick fix!