craftcms / commerce

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

[5.x]: Issues with multiple variants & inventory #3468

Closed sunnylawn closed 2 months ago

sunnylawn commented 2 months ago

What happened?

Description

Installed Craft Commerce, added 'standard' products with single variants, all good. Variants have fields such as single image on them to allow for individual photos of variants.

Adding in a product that then has multiple variants has created multiple problems. When you edit a variant, the single image field show, missing the upload part of the field and doesn't do anything. There is a JS error in console as the first image will show.

Screenshot 2024-04-29 at 17 35 20

Then if you try changing any information on the product, when saving you just get an unable to verify data submission?

`yii\web\BadRequestHttpException: Unable to verify your data submission. in /var/www/html/vendor/yiisoft/yii2/web/Controller.php:220 Stack trace:

0 /var/www/html/vendor/craftcms/cms/src/web/Controller.php(175): yii\web\Controller->beforeAction(Object(yii\base\InlineAction))

1 /var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php(98): craft\web\Controller->beforeAction(Object(yii\base\InlineAction))

2 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(176): craft\controllers\ElementsController->beforeAction(Object(yii\base\InlineAction))

3 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('edit', Array)

4 /var/www/html/vendor/craftcms/cms/src/web/Application.php(349): yii\base\Module->runAction('elements/edit', Array)

5 /var/www/html/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('elements/edit', Array)

6 /var/www/html/vendor/craftcms/cms/src/web/Application.php(317): yii\web\Application->handleRequest(Object(craft\web\Request))

7 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))

8 /var/www/html/web/index.php(12): yii\base\Application->run()

9 {main}`

When you then go to Commerce > Inventory it just constantly spins. JS errors thrown again, with the 500 being thrown on this:

`Error: Call to a member function canSave() on null in /var/www/html/vendor/craftcms/commerce/src/controllers/InventoryController.php:250 Stack trace:

0 [internal function]: craft\commerce\controllers\InventoryController->actionInventoryLevelsTableData()

1 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

2 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)

3 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('inventory-level...', Array)

4 /var/www/html/vendor/craftcms/cms/src/web/Application.php(349): yii\base\Module->runAction('commerce/invent...', Array)

5 /var/www/html/vendor/craftcms/cms/src/web/Application.php(650): craft\web\Application->runAction('commerce/invent...', Array)

6 /var/www/html/vendor/craftcms/cms/src/web/Application.php(311): craft\web\Application->_processActionRequest(Object(craft\web\Request))

7 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))

8 /var/www/html/web/index.php(12): yii\base\Application->run()

9 {main}`

This is not on a real project so not time critical.

Craft CMS version

Craft CMS Pro 5.0.5

Craft Commerce version

5.0.0-beta.3

PHP version

8.2.13

Operating system and version

OSX 14.4

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

Blitz 5.2 / CKEditor 4.04 / Navigation 3.00-beta3 / SEOMatic 5.0.2 / Sprig 3.0.1 / Vite 5

linear[bot] commented 2 months ago

PT-1675 [5.x]:

nfourtythree commented 2 months ago

Hi @sunnylawn

Thank you for your message and for raising these.

On your points:

Image upload/variant editing

I am unable to replicate the issue you described, with single and multiple variants. Both creating new products/variants and editing existing ones. I was always able to upload new assets and everything worked as expected. Are you able to update to the latest version of Craft 5 and check to see if things are working?

Inventory listing issue We have just pushed up a fix which I believe might solve the issue for you.

Could you change your craftcms/commerce requirement in your project's composer.json to:

"require": {
  "craftcms/commerce": "5.0.x-dev#0f3ba566295fa8b032887a3cace8e2979685b860 as 5.0.0-beta.3",
  "...": "..."
}

Then run composer update and check to see if that is still an issue.

Thanks!

sunnylawn commented 2 months ago

So have updated craft and then updated commerce.

The Commerce updated fixed the Inventory, thats now working as expected, but JS error still appearing on the product slide-outs when using muliptle variants, Also noticed that the option to remove the image from the field has gone too. And that adjusting something , hitting save, is still triggering that unable to verify data error.

I’ll spin up another project and just test it to see if its something to do with that install.

On 30 Apr 2024, at 11:22, Nathaniel Hammond @.***> wrote:

Hi @sunnylawn https://github.com/sunnylawn Thank you for your message and for raising these.

On your points:

Image upload/variant editing

I am unable to replicate the issue you described, with single and multiple variants. Both creating new products/variants and editing existing ones. I was always able to upload new assets and everything worked as expected. Are you able to update to the latest version of Craft 5 and check to see if things are working?

Inventory listing issue We have just pushed up a fix which I believe might solve the issue for you.

Could you change your craftcms/commerce requirement in your project's composer.json to:

"require": { "craftcms/commerce": "5.0.x-dev#0f3ba566295fa8b032887a3cace8e2979685b860 as 5.0.0-beta.3", "...": "..." } Then run composer update and check to see if that is still an issue.

Thanks!

— Reply to this email directly, view it on GitHub https://github.com/craftcms/commerce/issues/3468#issuecomment-2084927382, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4PGEODERU7LH7ASLUVY3JTY75WGVAVCNFSM6AAAAABG6VW4WKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBUHEZDOMZYGI. You are receiving this because you were mentioned.

nfourtythree commented 2 months ago

Now that version 5 has been released I am going to close this issue.

If you managed to replicate the other issue please re-open this and we can look into it.

Thanks!

sunnylawn commented 2 months ago

Yeah, tested on another project and was all good, ended up uninstalling commerce and reinstalling and it seems to of done the trick.

sunnylawn commented 2 months ago

Sorry @nfourtythree think I can recreate this more reliably now... Was all working good, adding variants all working as expected, but then realised the variants were missing a field. Adding that additional field onto the variants then seems to cause that data submission error and stop images etc being removed (the JS error). If you create a new product, it all works fine.

So seems to be if a field is added to variants, products/variants that existed before that field was added it then gets the issue?