craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
215 stars 169 forks source link

[5.x]: TypeError triggered when adding discount condition #3538

Closed TheFunkyMonk closed 3 weeks ago

TheFunkyMonk commented 3 weeks ago

What happened?

Description

When creating a discount for a condition where the cart contains 6 or more items, saving the discount triggers the following error:

craft\commerce\services\Stores::getStoreById(): Argument #1 ($id) must be of type int, null given

2024-06-10 at 15 20 04

Steps to reproduce

  1. Create a new discount under Store Management > Discounts
  2. Set the Match Order rule to Total Qty > is greater than or equals > 6

Expected behavior

Discount can be saved

Actual behavior

TypeError displays

Craft CMS version

5.1.10

Craft Commerce version

5.0.9

PHP version

8.2.19

Operating system and version

Linux 6.5.0-15-generic

Database type and version

MySQL 8.0.33

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

CKEditor 4.0.6 Colour Swatches 5.0.0 Control Panel CSS 3.0.0 Craft Commerce 5.0.9 Default Dashboard 3.0.0 Field Manager 4.0.0 Guide 4.0.0-beta.1 ImageOptimize 5.0.1 Image Resizer 4.0.0 Neo 5.0.2 No-Cache 3.0.2 PayPal Checkout for Craft Commerce 3.0.0 Redirects 5.0.0 Retcon 3.1.0 SEO 5.0.3 Servd Assets and Helpers 4.0.3 Stripe for Craft Commerce 5.0.1

linear[bot] commented 3 weeks ago

PT-1809 [5.x]: TypeError triggered when adding discount condition

lukeholder commented 3 weeks ago

Thanks for reporting this issue. We have fixed it for the next release.

To get the fix early, change your craftcms/commerce requirement in composer.json to:

"require": {
  "craftcms/commerce": "5.x-dev#08bce9de597355ec34e5c602c639a2ddaa0b9d54 as 5.0.9",
  "...": "..."
}

Then run composer update.

We will update this ticket once the release it out. Thanks again.

nfourtythree commented 3 weeks ago

Commerce 5.0.10 has now been released with this fix included.

Thanks