We currently support optional attributes, but the logic is incomplete and lacks tests.

Optional attributes are used when the attribute might only be used for specific products or variations.
For example Color when not all products of that type have a Color.

Missing logic in ProductVariationAttributesWidget::formElement():
1) Hide attributes with no values (#access -> FALSE)
2) If an optional attribute has no "_none" option (meaning that it's defined on all relevant variations), make it required.

Plus, a test.

Comments

bojanz created an issue. See original summary.

bojanz’s picture

Title: Hide attributes with no values on the add to cart form » Clarify optional attribute functionality
Issue summary: View changes

Expanding to cover other aspects of optional attribute handling

harings_rob’s picture

Assigned: Unassigned » harings_rob
harings_rob’s picture

Status: Active » Needs review

PR: https://github.com/drupalcommerce/commerce/pull/374

I think I have it covered by the tests, I kept them simple and only target the changes I made.

  • bojanz committed bdcd17f on 8.x-2.x authored by harings_rob
    Issue #2706207 by bojanz, harings_rob: Clarify optional attribute...
bojanz’s picture

Status: Needs review » Fixed

Thanks!

bojanz’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.