Add conditional logic in Woocommerce composite products scenario
Scenarios are great, but still very basic as far as conditional logic is concerned.
Here's a list of interesting additions:
- Enable Component specific scenarios as opposed to having to systematically involve every component of composite product
- Conditional components (if a specific component is selected then other component becomes available/unavailable, defaults to a specific value or is hidden/displayed).
Regarding Component-specific scenarios:
Dependencies could be implemented simply using a sequential logic describing the allowed alternatives when following a progressive selection path, or by using a combinational logic to describe the allowed solutions without caring about the progression.
The first could be implemented using simple sets of rules that relate the allowed options of a Component to the options made in the previous Components. *However*, to be practical this approach would only allow selecting options progressively, ie starting with the 1st Component, then moving to the 2nd, and so on.
Scenarios follows the second approach which doesn't have any "memory" - this means that you can create any sort of dependency you like, including multi-component dependencies, without having to force a progressive selection route. In the docs example, you can start by selecting a Lens that you like without knowing or caring which Cameras it is compatible with.
Some applications assume dependencies which have an inherent progression (ie *this* Camera is not compatible with *that* Lens), but there are cases where this is not desirable or possible, because all components are of equal importance to the whole.
The downside is that Scenarios are more complex. If the configuration of your Composite needs to have a simple progression and your restrictions are based on this progression, you will need a slightly analytical approach to break down the problem into Scenarios.
In short, Scenarios forces you to think about which items can co-exist in a possible configuration - put simply, you need to define all possible outcomes.
Reagrding Conditional components:
This can be done using Scenarios. If you just define a Component as optional, you can make the None option available in certain Scenarios. In those Scenarios, it won't be possible to select anything for the specific Component, which is the same as saying that the Component itself is conditional.
Conditional default options is really overkill - such a niche feature would never justify its development and maintenance cost.