craftcms / commerce

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

[4.x]: Broken preview for products #3215

Closed bavodeclercq closed 1 year ago

bavodeclercq commented 1 year ago

What happened?

Description

The live preview feature for products in Craft Commerce is not functioning correctly. When accessing the preview, a blank screen is displayed, and in the network tab of the browser's developer tools, a 400 error is observed.

yii\web\BadRequestHttpException: Post request required in /var/www/html/vendor/craftcms/cms/src/web/Controller.php:465
Stack trace:
#0 /var/www/html/vendor/craftcms/commerce/src/controllers/ProductsPreviewController.php(43): craft\web\Controller->requirePostRequest()
#1 [internal function]: craft\commerce\controllers\ProductsPreviewController->actionPreviewProduct()
#2 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#4 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('preview-product', Array)
#5 /var/www/html/vendor/craftcms/cms/src/web/Application.php(304): yii\base\Module->runAction('commerce/produc...', Array)
#6 /var/www/html/vendor/craftcms/cms/src/controllers/LivePreviewController.php(121): craft\web\Application->runAction('commerce/produc...')
#7 [internal function]: craft\controllers\LivePreviewController->actionPreview('commerce/produc...', 1)
#8 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#10 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('preview', Array)
#11 /var/www/html/vendor/craftcms/cms/src/web/Application.php(304): yii\base\Module->runAction('live-preview/pr...', Array)
#12 /var/www/html/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('live-preview/pr...', Array)
#13 /var/www/html/vendor/craftcms/cms/src/web/Application.php(289): yii\web\Application->handleRequest(Object(craft\web\Request))
#14 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#15 /var/www/html/web/index.php(12): yii\base\Application->run()
#16 {main}

This issue is not limited to my specific installation but can also be replicated in the "Spoke and Chain" demo. It's worth noting that the live preview of entries works correctly, indicating that the problem specifically affects the live preview of products.

Steps to reproduce

  1. Go to a product in the CP.
  2. Click on the "Preview" button.

Expected behavior

The live preview should display the product information correctly, allowing for a preview of how the product will appear on the website.

Actual behavior

The live preview shows a blank screen, and the network tab in the browser's developer tools displays a 400 error.

Craft CMS version

4.4.15

Craft Commerce version

4.2.11

PHP version

8.1.16

Operating system and version

Linux 6.3.12

Database type and version

MySQL 8.0.31

Image driver and version

Imagick 3.7.0

Installed plugins and versions

bossanova808 commented 1 year ago

Yep seeing this too. Error is: Unable to verify your data submission. - live preview of everything else seems to be working fine, it's just products as far as I can determine.

lukeholder commented 1 year ago

Looks like this broke 2 weeks ago in a recent Craft CMS release, since this commit: https://github.com/craftcms/cms/commit/c0a37e15cc925c473e60e27fe64054993b867ac1

I will raise the issue with the CMS team and get back to you both soon. Thanks.

bossanova808 commented 1 year ago

Sounds about right, I've been away most of the last couple weeks but my staff mentioned they've been seeing it a while. (Be handy if they'd told me earlier!)

Thanks Luke

bossanova808 commented 1 year ago

What's going on with this one please? Kind of an important piece of functionality we'd like to get working again ASAP...

lukeholder commented 1 year ago

Apologies for not responding here. We looked into it and this was fixed upstream in Craft CMS and the fix will be in the next Craft CMS release.

lukeholder commented 1 year ago

Fix is here:

https://github.com/craftcms/cms/commit/a987c99e38c93d97d5c4d7569fbbe7d5dd8ab1cb

bossanova808 commented 1 year ago

No dramas - so the next point release, not 4.5, right?

bossanova808 commented 1 year ago

Just confirming this is all working again for us with the latest Craft update...

nfourtythree commented 1 year ago

Thanks for updating us @bossanova808 !