When you have multiple people working on and managing your store it quickly becomes unclear who made which change and when. Natively there’s no way to keep track for example who changed the product price of a product or its stock availability. 

In this post I’ll show how a simple product change log can be created and displayed with the product edit page. The change log can keep track of different product changes, what I’m going to be focussing on most is changes of the product meta data (such as price, inventory, tax status etc).

Logging Product Changes

First thing to do is actually logging the changes when a product is saved. The following code snippet saves all data automatically when saving a product through the edit page. 

The changes are stored in the comments database table as a product_log comment type. Storing it in the comments table is the easiest and most scalable solution here and similar to WooCommerce order notes.

Storing data in the comments data does require a small bit of additional code, this ensures the logs are not loaded as reviews by WooCommerce Core – as those are also stored in the comments table. The following snippet ensures that no longer is the case.

Display Logged Product Changes

Now that we’ve successfully stored the product changes, its time to display them. To display them a new product tab is created in which the logs will be listed in a simple table.

This last snippet will create the tab and display the change logs accordingly.

After implementation of the three code snippets, this is how the change log will look like (after you’ve made some changes ;-)

About the author: Jeroen Sormani is actively building WordPress, WooCommerce and Easy Digital Downloads plugins. Slightly obsessed by writing high quality code.
Follow Jeroen on Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *