commerce icon indicating copy to clipboard operation
commerce copied to clipboard

[4.x]: "Conditional Field" the field will not appear automatically if the conditions match.

Open rezzart-id opened this issue 3 years ago • 6 comments

What happened?

Description

The field will not appear automatically if the conditions match. It looks like conditional fields work fine on Entry Type but not on Product Type.

Steps to reproduce

  1. Go to System Settings on the Commerce.

  2. Click on the Product Types and go on the Product fields tab to edit the Field Layout.

  3. Add PlainText field, then click on gear icon to add the rule.

  4. Add Entry rule condition, select the field that will follow the condition (For example 'Lightswitch button).

  5. Save it.

  6. Go to Products on the Commerce navigation, and create or edit a product.

  7. Click the lightswitch toggle button that we set earlier.

Expected behavior

The plaintext field will appear automatically if the conditions match.

Actual behavior

The plaintext field does not appear automatically, it needs to be saved first to display it.

Craft CMS version

Craft Pro 4.0.0-beta.3

Craft Commerce version

4.0.0-beta.1

PHP version

8.0.17

Operating system and version

Linux 5.10.47-linuxkit

Database type and version

MySQL 5.7.37

Image driver and version

Imagick 3.6.0 (ImageMagick 6.9.10-23)

Installed plugins and versions

"craftcms/aws-s3": "^2.0.0-beta.1", "craftcms/cms": "^4.0.0-beta.1", "craftcms/commerce": "^4.0.0-beta.1", "craftcms/redactor": "^3.0.0-beta.1", "nystudio107/craft-retour": "^4.0.0-beta.2", "nystudio107/craft-seomatic": "^4.0.0-beta.4", "verbb/navigation": "^2.0.0-beta.1", "verbb/super-table": "^3.0.0-beta.2", "verbb/vizy": "^2.0.0-beta.1", "verbb/wishlist": "^2.0.0-beta.1", "vlucas/phpdotenv": "^3.4.0"

rezzart-id avatar Mar 30 '22 02:03 rezzart-id

Products do not support the conditional fields live re-rendering due to not supporting drafts. This is planned to be added in the future.

lukeholder avatar Jun 15 '22 11:06 lukeholder

I feel like the option to have conditional fields should be disabled in the meantime? I was about to submit a bug report as I didn't know this limitation currently existed. Very much looking forward to it being added though!

robzor avatar Jul 15 '22 11:07 robzor

This is planned to be added in the future.

@lukeholder - Any hoped-for version for drafts to be released for products?

sjcallender avatar Sep 19 '22 01:09 sjcallender

@sjcallender we have it on the list for the next major version, due to the improved child element support planned in Craft 5.

lukeholder avatar Sep 19 '22 11:09 lukeholder

@lukeholder So will Craft Commerce 5 be released together with Craft 5, so sometime at the end of this year? I just stumbled over this, this very much feels like an unfinished feature. The UI is identical to entries, but conditions only uploading on page reloads make this borderline unusable. I agree with @robzor that it would've been better to hide the entire UI for conditional fields if they aren't fully supported. At the very least, the field layout editor for product types should display a warning about this – and maybe the product edit form should as well. Something like:

Some fields may become available or unavailable after reloading.

This could be displayed whenever the product field layout contains any conditional fields on the edit form. Though of course, getting dynamic conditionals to work on products would be much preferable.

MoritzLost avatar Mar 06 '23 16:03 MoritzLost

https://linear.app/craftcms/issue/COM-242/products-should-use-the-element-editor-controller

lukeholder avatar Nov 20 '23 11:11 lukeholder