Clean WordPress and Woocommrece Garbage

woocommerce garbage
Written by @kiosmerdeka

Clean Woocommerce Garbage

After you finish uninstalling Woocommerce, it’s a good idea to clean the database from Woocommerce plugin trash such as product attributes that don’t automatically disappear after the uninstall process.

Attention, do this at your own risk. Always backup your database before doing something serious.

Delete all Woocommerce product attributes

DELETE FROM jt_terms WHERE term_id IN(SELECT term_id FROM jt_term_taxonomy WHERE taxonomy LIKE 'pa_%');
DELETE FROM jt_term_taxonomy WHERE taxonomy LIKE 'pa_%';
DELETE FROM jt_term_relationships WHERE term_taxonomy_id not IN(SELECT term_taxonomy_id FROM jt_term_taxonomy);

Delete all WooCommerce products

DELETE FROM jt_term_relationships WHERE object_id IN (SELECT ID FROM jt_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM jt_postmeta WHERE post_id IN (SELECT ID FROM jt_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM jt_posts WHERE post_type IN ('product','product_variation');

Delete orphaned postmeta

DELETE pm FROM jt_postmeta pm LEFT JOIN jt_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;

Deleted product attributes still appear

The problem was because there were transient records in the table jt_options “_transient_wc_attribute_taxonomies” that kept a list of the attributes (also olders). I’ve deleted these transient records and now everything is fine.

DELETE from jt_options where option_name='_transient_wc_attribute_taxonomies';

How do You Determine the total size of a directory (folder) from the command line? (Linux)

Recently I found a great, Ncurses-based interactive tool, that quickly gives you an overview of directory sizes. Searched for that kind of tool for years.

  • quickly drill down through file hierarchy
  • you can delete e.g. huge temporary files from inside the tool
  • extremely fast
sudo apt-get install ncdu

ncdu is awesome! After installing it, just do this ncdu /. You will very quickly find the biggest files on the system. Also, press h while inside ncdu’s console interface. It has very useful shortcuts.

Baca juga  Download Files From Google Drive Using Wget

Leave a Comment