Woocommerce product category fields

Yeah, we step into Woocommerce chambers. This is a huge, good plugin, widely recognizable, used on many many e-commerce sites. They got nice product category taxonomy and it works fine. But what if we need a few more fields? It’s not that hard as you may think so, because Woocommerce is well written plugin, we can hook into it without any trouble.

We need four action hooks and three functions. I will use methods, because I prefer object oriented programming, but it’s pretty easy to convert it into functional programming. You may ask, why only three functions, when we want to use four hooks? Two hooks will be handled by one function. All right, let’s build our class. We will call it ProductCategory and will put it into \Phylax\WordPress\Theme\Library namespace to avoid any conflicts.

How to call this class? Well, use functions.php file of your theme of course.

And that’s it. This will work as soon as we add some fields… What field would you like to add? Let’s do something very simple at the beginning. Let’s add “External link” field for, well, external link for every category. We may need it for many reasons, you can figure out your idea why exactly. Let’s rebuild our class file.

Note, that I may did some typos here, I wrote it here, in WordPress editor, so do not feel angry when something isn’t right. Please feel free to post comments about it and I will certainly fix any mistakes.


  1. I think there is something wrong in function product_cat_edit_form_fields? The variable $term_meta is NULL? I added:
    $term_meta = get_option( ‘taxonomy_’ . $term->term_id );
    before the for-loop and now it works.
    Please correct me, if I’m wrong.

    • Ronald, you are absolutely right, thank you for noticing. As I wrote in the post, I wrote this code in WP editor, so I didn’t test it. Of course it should get option first, like it did in create_edit_update method. I corrected it, thank you again.

Leave a Reply

Your email address will not be published.