Problem/Motivation
When the "Vado group add to cart" form display is set to show the "Product variation attributes" widget, the group selected options don't reset after attribute selection change.
This is a problem, for example when unchecking the add on options, that are set to default on/enabled, and changing a product attribute, the price field displays the full calculated price, but the group options appear unselected.
Additionally, when adding that product variation to the cart, the "unselected" add on options will also be added.
Other than this issue (fixed with this small patch), using the product attributes widget appears to work well.
Steps to reproduce
- Set the order item type "Vado group add to cart" form display "Purchased entity" to use the "Product variation attribution" widget.
- Add a group with checkboxes (default enabled) to the product variation.
- When changing the product attributes, the group options to not clear/reset.
Proposed resolution
There is already a "TODO" comment in the related group add to cart form code.
// @todo currently only supports the variation title widget, not attributes.
Implement that TODO and reset the group add to cart form fields when the product attributes change.
Remaining tasks
MR patch incoming.
User interface changes
When using the group add to cart form and the product variation attributes widget, when changing the product attributes, the group selection will reset to the default configuration.
API changes
N/A
Data model changes
With thanks for the useful module!
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot 2025-05-20 at 9.58.26 AM.png | 109.16 KB | davidwhthomas |
Issue fork commerce_vado-3525364
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
davidwhthomas commentedComment #4
davidwhthomas commentedComment #5
tonytheferg commentedThanks for posting. Seems simple enough. NW as this will need test coverage before adding.
Comment #6
davidwhthomas commentedThanks for checking.
I had a look earlier and couldn't find any existing tests related to, for example the group add to cart form and clearing the group widget on product variation title selection change.
As the MR passed the existing pipeline tests, I have assumed this minor update is ok there.
However, do you have any recommendation on where such a test would best be added?
Comment #7
tonytheferg commentedI'm away from the office currently, but I'm not basing the requirement of needing tests off existing tests, but rather establishing the support of attributes. Currently the module doesn't claim to support attributes, so if we do offer to support attributes, it needs test coverage.
Comment #8
davidwhthomas commentedFair enough. FWIW in the meantime. Other than the group add to cart form widget not resetting to default when the product attribute selection changes (fixed with this patch), the commerce_vado module appears to work well when using the product attribute widget for the product variation selection.
Comment #9
davidwhthomas commentedComment #11
joshmillerAdded the test coverage tonytheferg asked for in #5 and pushed it to the MR branch (with 3.0.x merged in first, no conflicts):
tests/src/Functional/VadoGroupAttributesTest: a product with a Color attribute (Red/Blue variations, both referencing a checkboxes group that has one default item), rendered with the group add to cart form and the commerce_product_variation_attributes widget. The test changes the colour and the group selection, triggers the attribute element the way the widget's #ajax does (a POST carrying _triggering_element_name, so no JavaScript test is needed) and asserts that the variation switches while the group selection falls back to its default. A second step triggers a group checkbox itself and asserts the customer's selection is kept, so the reset only fires for attribute changes.
The test fails on 3.0.x without the MR change (the default group item is not re-checked after the attribute change) and passes with it; the MR pipeline is green. Drafted with AI assistance (Claude), reviewed and run locally by me on Drupal 11.4.6 / Commerce 3.3.9.
Marking RTBC. Thanks davidwhthomas.
Comment #13
joshmillerCommitted to 3.0.x as 15d4d1b (squashed, credit to davidwhthomas and joshmiller). Attributes on the group add to cart form are now covered by a test, so the widget is officially supported from the next release after 3.0.3. Thanks!
Comment #15
davidwhthomas commentedThanks!!
Comment #16
tonytheferg commentedDocs probably need updated as the scope has grown.