Here’s a quick tip from a question we were asked by Nick:
Any time I add attributes to my products, I want to display them on the product page and use them for variations. Is there a way to default this checkbox to ‘checked’ instead of ‘unchecked’?
For reference, when you add attributes to a product, you’re given the option to show them on the product page (which adds them to the “Additional Information” product tab), and if the product is variable, you can use these attributes to create variations.
By default, these settings are unchecked for new products:
We can instead default them to
checked if we’d like to with 2 lines of code.
To change the first checkbox and default to showing all variations on the product page, you can add this code snippet to your child theme’s
functions.php or your custom code plugin:
add_filter( 'default_attribute_visibility', '__return_true' );
If you’d like to also default to using attributes for product variations, you can set this checkbox as “checked” by default using this snippet:
add_filter( 'default_attribute_variation', '__return_true' );
Any time a variation is added with these snippets active, these checkboxes will always be checked.