Remove All Variations With No Parent Product

Sometimes when you delete a WooCommerce variable product, it does not delete the variations of that product; this can cause issues! In order to delete them, try the following.

Note: Proceed with caution! Always do a database backup first before running a script like this.

Firstly, add this function to your themes functions.php file:

Secondly, add this function to you functions.php file.

Finally, once the snippets have been added, load any page on your website, and the function will run. Once complete, you can either remove all of this code, or simply remove the code we added in step 2.

All done! Don’t you fell cleansed?

2 Comments

  1. vik says:

    i need a similar functions that remove all variation of an X post when i call…have information about where i can find it?

  2. Jenny Read says:

    When I delete one attribute and save it does not delete the variations associated with that attribute. I originally had two sizes and, as I no longer offer two sizes I do not add this as an option and the size is in the description. The problem is the deletion of the attribute doesn’t change the prices from – to and it leaves double the variation combinations in the backend. I really would like to delete the variations associated with the attributes I have deleted to be deleted as well and the from price shown accordingly. Any idea as to how I can do this for each product I want to change. Many thanks

Leave a Reply

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