Usually when selling goods that come in different size and colors, a different SKU would exist for any size/color combination that you sell, thus a unique variant.
So, when that item becomes low in stock (S
tock K
eeping U
nit), you can order more in.
In Craft Commerce we do not automatically generate every combination of variant based on the custom fields attached to a variant because most stores never sell every combination, and also, not every custom field is a unique aspect of that variant.
If more options are added to a product, there is nothing forcing you to make every combination as a variant, you could just use an option/custom field to mark a single variant as special (i.e Gold Edition).
If you are selling something that has a lot of options that customers are required to choose from each option, there is nothing stopping you from building a UI on the front end that makes selecting a variant possible based on all the options of all the custom fields. In that case your front end UI is building a query for a variant (craft.commerce.variants
).
If you're not really selling a unique single SKU, but rather wanting a 'build a product' type product based on smaller SKUs, like building a bike, then you would need to build that yourself on the front end and/or with a plugin. That plugin would track what is in the cart, and which items still need to be added to complete the bike.
An alternative to that is building a custom purchasable with a plugin. This would allow you to expose the building of the purchasable element to the customer (with any options or custom logic you wish), and once the purchasable is saved by the customer, they can add it to the cart.
Lastly, if you don't want to go down the custom purchasable route, you can always just use generic options
params when adding a product to the cart to allow any extra customer choices for the product. If the price is the same for the product regardless of the option chosen, this might be the easiest path if you have a huge amount of options and don't want to have a variant for each. The only thing you would want to do is validate the options for the current product.
The line item options feature mentioned above can also be combined with a small plugin that modifies the price of the line item based on the options choosen with the onPopulateLineItem event. The plugin would use the event something like this:
craft()->on('commerce_lineItems.onPopulateLineItem', function($event){
$purchasable= $event->params['purchasable'];
$lineItem = $event->params['lineItem'];
if(isset($lineItem->options['giftWrapped']) && $lineItem->options['giftWrapped'] == 1){
$lineItem->price = $lineItem->price + 1;
$lineItem->salePrice = $lineItem->price;
$lineItem->saleAmount = 0;
}
}
Remembering that using the options method above will not be compatible with any stock tracking or inventory features now or in the future.
Let me know if you have any follow up questions and I can improve the answer above.