WooCommerce Products make use of WordPress’s Custom Post Type feature, but one thing you’ll notice is missing is revision support. WooCommerce has deliberately omitted support for revisions because the majority of the content in a WooCommerce product is stored as metadata. The WordPress revisions system only covers post content which only covers the product description.
So even with revision support, product information such as price, shipping data, and everything else in the Product Data section would not be revisioned.
Sure, but I’d still like revisions for product descriptions
We have a customer that changes product descriptions on a regular basis and has had then need to go back and look at previous content. Here’s how we added support for product revisions on his site. Remember this will NOT save revisions for anything other than the main product description:
9/2/20 UPDATE: Use this new snippet:
/*
* Add Revision support to WooCommerce Products
*
*/
add_filter( 'woocommerce_register_post_type_product', 'cinch_add_revision_support' );
function cinch_add_revision_support( $supports ) {
$supports['supports'][] = 'revisions';
return $supports;
}
Not this older version, it no longer works:
/*
* Add Revision support to WooCommerce Products
*
*/
add_filter( 'woocommerce_register_post_type_product', 'cinch_add_revision_support' );
function cinch_add_revision_support( $args ) {
$args['supports'][] = 'revisions';
return $args;
}
Hopefully not the end of the story
There are plenty of people out there who would like to get revisions added to WooCommerce Products as a core feature. One way to do that would be for WordPress to implement revisioning for post meta. Let’s hope WordPress brings that to the table at some point.
11 Comments
This article sounds like it would share a snippets that brings revisions to products, but the code is nowhere to be found? Unless this is only a type of “Hey, client requested something, and we did it” kind of post?
Thanks for the clarification, if I’ve missed the obvious :)
Hi Charles,
It sounds like you can’t see the gist script? Here’s a direct link if that’s the case: https://gist.github.com/spigotdesign/157cb4eafa55a4c0b8e52f17f85d8819#file-product-revision-support-php
~ Bryan
Hello, thanks for the link, and in deed, the page does not display any gist scripts on my setup (Mac OS X 10.11.6, Chrome 78.0.3904.108, if it can be useful to you)
Very strange, works on all browsers for me. How about this link: https://gist.github.com/spigotdesign/157cb4eafa55a4c0b8e52f17f85d8819
Where can the revisions be viewed? I don’t see any changes on the actually product pages themselves after implementing the code.
Hi Dayle,
I haven’t checked this in a while but it doesn’t appear to work any longer. I’ll do a bit of research and see if we can find out why and perhaps a new method…
Was there any outcome to an alternative solution
Hey Aaron – I’ve updated the code with the changes necessary to get this to work. Simply change
$args
to$supports
Greetings!
great way to check the audit trail of the products. Right now we’re experiencing … duplication of product records with differing information.
Where would I add this snippet though?
Hi Paul. You can put this snippet in your
functions.php
file, or better yet, a custom functions plugin.Thanks mate, this saved me some time. ;)