2
votes

The custom attributes of a variable product are required. How can I make some of those attributes optional?

I've searched in woocommerce for the optional option, but there is none. So I'm wondering if there is an option to add this trough the Wordpress functions.php

What I actually want is an option to select if the attribute is optional or required.

1
I had problems with flexibility of variable products as well. Sadly the solution I implied was an ugly fix that removes required from my field with JS. Not really a good solution though :pWimanicesir
What do you mean exactly by product attribute required or optional in a variable product? Could you clarify please…LoicTheAztec
@LoicTheAztec The product has attributes to select by the user before it's possible to send the product to the cart, you need all the attributes to have a value. What I want is that some of those attributes are required, and some of them are not.dejonge
Ok I get it… Think about it first: As a product variation is being selected from a combination of the product attribute dropdowns, You can not have an optional dropdown because no product variation will be selected in that case and customer will not be able to add something to cart. So you need to thing different what you are trying to do…LoicTheAztec
You cannot have an optional dropdown, but you are able to set a variation to support "Any" choice for a particular attribute, which is essentially making that attribute optional.helgatheviking

1 Answers

2
votes

I've just had the same issue where I have a list of dropdown attributes for a product, where only some of these attributes need to be selected. I understand what LoicTheAztec is saying and must assume this is how WooCommerce think as well which is why I don't think there's an elegant answer in code. However, the simplest answers are the best.

What I did is just add a --NONE-- attribute value at the start of the list. Set this as the default value and Robert's your mother's brother.