Posted In

Add Markup to WooCommerce Products

WooCommerce & Is Awesome

Adding markup to a well coded WordPress theme is relatively straight forward and doesn’t take very long to get setup.

I covered how to add markup to your WordPress theme in a previous post, but I recently needed to apply markup to an e-commerce site using WooCommerce.

It’s surprisingly easy to do. You’ll need to be using a child theme for the steps that follow.

1. Setup the necessary function in the functions.php file for your theme

Add the following to your functions.php file. It creates a custom function, schema_org_markup.

2. Call schema_org_markup() In Your Header

Open up the header.php file for your child theme and find the html tag, usually towards the top. You’ll want to call the schema_org_markup function inside that html tag, like so:

3. Create a WooCommerce template file in your child theme

Create a directory in your child theme folder named woocommerce. Inside the woocommerce folder, create another new folder named single-product. Inside the single-product folder, create a file named price.php. The contents of your price.php file should look like this:

4. All Done

That’s all that’s required to add markup to individual WooCommerce product pages. Pretty simple.

If you run into any issues or it doesn’t seem to be working for you, let me know. I’ve only tested this with two themes, Vantage and Virtue. Remember, this only works with well-crafted WordPress themes. Doing this with purchased themes from ThemeForest or other paid theme marketplaces can be significantly more difficult.

Comments are open so let me know if you have any issues, additions, questions, or suggestions.

Well, now what?

Work with Me

I'm available for hire and always taking new clients, big and small. Got a project or an idea you'd like to discuss? Startup plan but no developer to make it happen? Just get in touch, I'd love to see if I can help you out!

Leave some Feedback

Got a question or some updated information releavant to this post? Please, leave a comment! The comments are a great way to get help, I read them all and reply to nearly every comment. Let's talk. :) is proudly hosted by DigitalOcean

  • Vivek Padhye

    Just what I was looking for! Can we add schema for reviews as well?

  • Michael Christensen

    Tyler, thanks for the walk-through.

  • Nice – could make an ez plugin for this…

  • Omar

    Hi thanks for the trick, but I still not have tag name on structured data, my site is

  • Hi there!

    I’d be happy to lend a hand. Would take some additional modifications to the code in this tutorial, but has many properties available for use with reviews.

    Email me at [email protected] or [email protected] if you want help or have more questions.

  • Eoin Bern

    Parse error: syntax error, unexpected ‘function’ (T_FUNCTION), expecting ‘{‘ in /home/digilzcr/public_html/wp-content/themes/vantage/functions.php on line 451

    What does this mean? I used the exact code as above in point 1

  • Thank-you sir!

  • Evan Henry

    How would these work for adding markup to product variations?

  • Little Tiger Gifts

    Hi Tyler, great article, one of only a few out there so thank you. I have added the above code to my Woocommerce site which is using WooThemes Canvas theme but for some reason the itemtype for all my test products is being set to ‘Article’ rather than ‘Product’. Category and Shop pages are being set to correctly Product itemtype. Example product url is http://www littletigertest co uk/product/les-papoum-elephant-soft-toy-moulin-roty-copy/

    I know you must be busy so I am just chancing my luck for a reply 🙂

    Thanks Steve.

    • Hey Steve, ever get it working? If not I’d be happy to have a look. Let me know.

      • Little Tiger Gifts

        Hi Tyler, thanks for responding, the WooThemes Canvas theme I am using does this out of the box. Adding the extra code simply broke it!

        I should have checked first before assuming it did not.


        • Good to know! Seems like more and more themes are integrating markup, especially the WooThemes folks.

  • Slight correction to your code required as it’s defaulting WooCommerce products to articles.

    Otherwise working great.

    • Interesting!!

      Really appreciate you bringing this up.

      I’ll have a major revision ready within a few weeks hopefully that will let you fill woocommerce with all the microdata you could want (that may be a bit of an exaggeration, but I’ll be taking feature requests).

      I may have said too much already, keep an eye out.

      Martin, I’ll update the post with your properly working code momentarily.

      • LOL… Your mistake was “I’ll be taking feature requests” (watches the inbox explode!) 😉

        Glad it was useful and definitely be interested to see what developments are in the wind. I’m looking at how to incorporate in volume discount data (max/min price) and multi-currency information based on the Aelia currency switcher plugin so got a bit list of “would be nice” to incorporate in..

        Let me know if you need a critical eye to cast over any dev code…

  • Fernando De Los Santos

    Can this code be adapted to work with WP E-Commerce? or is there a plugin or script that you can recommend for WPEC? Thank you!

    • Absolutely. There’s no plugin I can recommend for WPEC. I’d be willing to develop something. I’d need access to a demo WPEC site though for testing, would just make things so much faster if I didn’t have to setup WPEC with products and everything.

      Do you happen to have a site using WPEC that I could have access to? Or would you be willing to set one up?

  • Why can’t you just filter the default schema like you can in Genesis?

  • Martha van Berkel

    Tyler, love that you have enabled people to add this themselves. For people who just want it done, and comprehensively so you get the best results from your search results, check out the WordPress Plugin made by Schema Apps –

  • Tyler. Thanks for this information as it is very informative. I have a small question. I currently have a site that is using WooCommerce and the theme from WooThemes seems to have most of the product tags. However, it does not have “itemcondition”. Is there as way you can think of that I can simply add only the itemcondition schema?
    7.27 New

    • David Changaris

      did we ever get a fix for itemcondition and woocommerce for google merchant validation?

  • Александр Левицкий

    It works perfectly! Thank you so much! This article really made my day! Thank you thank you thank you!

  • Pingback: Tips for selling digital products with WooCommerce - ReadySpace Indonesia()

  • Iain Henderson

    Hi, many thanks for the easy walk through! I am getting an error from Google Webmaster though as all my category pages are being marked up as ‘product’ pages with no name. I’m using the Storefront theme. Any ideas what needs to be changed? Thanks, Iain

  • Pingback: Schema for WooCommerce()

  • Hey

    I found your blog through woocommerce, and their post about selling digital goods.
    If you could help me solve a problem, or suggest a solution, it would be amazing.

    I have a website built on WordPress, and Woocommerce.
    It sells a digital / printed magazine. Whihc means, that the same magazine issue can be bought in printed and online versions.
    But, we want to sell the digital version in “Zinio” format”, which means, that the licence a person bought, would allow them to read the magazine online, on their pc, laptop, smartphone, tablet, without dowloading it to their computer. To prevent them from sharing the pdf file of the magazine.

    is this possible on WooCommerce?

    With best wishes, thank you, Martyna

  • I’d like to display our products as Rich Cards on Googles search result pages but for that you need more structured data. My products are missing the values for “brand” and the “MPN”. Do you know a solution how to echo such values when you use an additional product attribute “brand” in Woocommerce?
    Here you find more informations about the markup for rich cards:

  • It implemented the scheme but getting name error, is there any pice of code i have to add ? I have woocommerece store