Ask SkyVerge

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:

woocommerce Default Attribute settings

Default Attribute settings

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' );

WooCommerce attributes used for variations default

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' );

WooCommerce attributes viewed default

Any time a variation is added with these snippets active, these checkboxes will always be checked.

Published by Beka Rice

Beka leads product direction for SkyVerge, focusing on new features for our plugins and Jilt. She spends a lot of time on research and interviews, but likes to write so she has an excuse to spend more time jamming out to anything from The Clash to Lady Gaga.

4 Comments

  1. This is no longer relevant.

    See https://github.com/woothemes/woocommerce/issues/7573. They removed both filters referenced.

    See https://github.com/woothemes/woocommerce/pull/7574. They added a new filter to handle this, “woocommerce_attribute_default_visibility”.

    • Hey @Allpro, thanks for the heads up! It’s unfortunate that there’s no longer a filter around using the attributes for variations, but will keep an eye on this for further changes.

  2. We use the Authorize.net AIM gateway and Paypal Express Gateway. I need to include the product’s attribute when exporting sales info to Authorize.net or PayPal.

    Is there any easy way to include the product’s attribute when exporting to Paypal or Authorize.net? I was hoping there is a simple function(s) that I can drop in my function.php file to accomplish this.

    • The AIM gateway should include the product attributes in the line item description area. This is also the case for the PayPal Express gateway (in most instances) — if you’re not seeing them, I’d recommend that you open a support ticket with WooCommerce to have their team take a closer look 🙂

Hmm, looks like this article is quite old! Its content may be outdated, so comments are now closed.