Support

Account

Home Forums ACF PRO Adding fields to WooCommerce Attributes (not attribute terms)

Solving

Adding fields to WooCommerce Attributes (not attribute terms)

  • I assume this is possible, but probably with more digging into things than I’ve been able to do…

    WooCommerce has a bunch of taxonomies associated with it. One is Attributes, commonly used for things like “Shirt Color”, and then under that attribute would be terms, like “Red”, “Yellow” and “Blue”. Here’s how these are represented in the backend UI:

    Attribute list/add screen

    Something seems a bit odd with the attributes, they have an edit URL like this that does not reference a post_id or anything, and the numbering starts at 1 and increments with each attribute:

    wp-admin/edit.php?post_type=product&page=product_attributes&edit=1

    The terms are simple, which is why I guess it’s easy to add fields there with the normal taxonomy selections in ACF:

    wp-admin/edit-tags.php?taxonomy=pa_altacom-ceramics&post_type=product (list of terms)

    wp-admin/term.php?taxonomy=pa_altacom-ceramics&tag_ID=2804&post_type=product&wp_http_referer=%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dpa_altacom-ceramics%26post_type%3Dproduct (editing an individual term)

    And you can see here we use ACF to add a field for an image to each term:

    Our addtion to an Attribute Term

    Hope that all makes sense – we want to add a field not at the “term” level (we’ve already done that), but at the attribute level, which seems to be hard because Woo is doing something unique here…

    Technically we could add the field to the terms, but that would mean setting a few fields on a few thousand terms, which would be kind of laborious.

    Any ideas?

  • Did you ever solve this? I was looking for something similar and hope to have found a solution in:

    Adding Custom Post Type UI. Then add a new custom posttype like “Attribute extras”. After that you can add a new group in ACF and add an image and extra description for example. Also you add a Taxonomy field with the field name matching the slug of the Attribute. You do this for each Attribute (in my case about 30).

    Finally when you add a new “Attribute Extra” you use the Title to match the slug of the actual attribute. In front you then make some custom code to display the image instead of the attribute value.

    Still testing this as I want to import all (2000+) Attribute Extra’s. I’ll let you know if it works

  • The page in question is a custom admin sub page that mimics a taxonomy admin page. I haven’t got a clue how this is added or if there is any way to change it. I did a search on the subject and found no information on changing this page. Changing this page would require WC having some type of action hook that runs when showing this page that would allow you to add ACF field groups to the form. It appears that the only source of information on if this can be done would be WC. If you can get information on if/how it is possible to alter this page then I could probably help you to add ACF fields to the page.

    Then the next problem would be where the information is actually stored and how to retrieve it because this page is simply an interface that allows you to add product attributes. From my understanding of this, each “attribute” that is added is a actually a new custom taxonomy and then then list for each of these has sub terms. So the interface is actually letting you create your own custom taxonomies associated with WC. So there really isn’t anywhere that this information is stored or to store any information associated with it. This would be like having information stored that is used on all “categories” or “tags” there is nowhere in WP to store information like this. So even if you could figure out how to alter this page I think that the effort would be wasted.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.