Problem/Motivation
Currently when a product has only one variation, the variation dropdown still renders. We should hide it and only show the add to cart button.
Proposed resolution
Check variation count. If one set the value as a #value in Form API
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | do_not_display-2660300-2.patch | 1.93 KB | mglaman |
Comments
Comment #2
mglamanPR: https://github.com/drupalcommerce/commerce/pull/319
Comment #4
bojanz commentedCommitted.
Comment #6
kaipipek commentedIs it true that this functionality is still not in production after seven years?
Comment #7
jsacksick commentedNo?
Comment #8
kaipipek commentedWhere is this code snippet from? All our products are rendered with a variations dropdown even when they have just one variation.
Comment #9
kaipipek commentedWhere is the hide_single setting in admin UI?
Comment #10
djroshi commentedHey, I stumbled across this as I was wondering the same thing. Turns out this checkbox is on the order item type (as opposed to the product or product variation)
1. Go to /admin/commerce/config/order-item-types
2. On the order item type click the arrow next to edit and select Manage form display
3. At the top, next to Default, click Add to cart
4. Next to Purchased entity select Product variation title
5. Click the cog wheel to display the widget settings
6. Check the Hide if there's only one product variation checkbox
There is more information about configuring the add to cart form here: https://docs.drupalcommerce.org/commerce2/developer-guide/products/displ...
Comment #11
kaipipek commentedThank you very much djroshi! I was already looking from a right place but I never figured out to change Product variations attributes to Product variation title. It was not very intuitive. :)
Comment #12
bessaston commentedThank you djroshi. This has irritated me for a couple of years, but now no longer.
Comment #13
bessaston commented