Deleting Woocommerce products using Mysql commands

mysql> DELETE relations.*, taxes.*, terms.*
-> FROM wp_term_relationships AS relations
-> INNER JOIN wp_term_taxonomy AS taxes
-> ON relations.term_taxonomy_id=taxes.term_taxonomy_id
-> INNER JOIN wp_terms AS terms
-> ON taxes.term_id=terms.term_id
-> WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
Query OK, 497631 rows affected (4 min 10.74 sec)

mysql>
mysql> DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');

Query OK, 1419875 rows affected (13 min 16.68 sec)

mysql> DELETE FROM wp_posts WHERE post_type = 'product';
Query OK, 66618 rows affected (51.91 sec)

Very useful commands especially when you need to purge large amount of products.

Fix 404 errors, Not Found, and Server Errors on WordPress/Woocommerce Site

According to wikipedia “The 404 or Not Found error message is a Hypertext Transfer Protocol (HTTP) standard response code, in computer network communications, to indicate that the client was able to communicate with a given server, but the server could not find what was requested.”

What happen is that the server could not find the file that are requested by the server. There are a few causes for these and these can be easily fixed.

There are common few fixes like refreshing browser, clear cache and cookie or amending .htaccess file.

For woocommerce site, I have found the cause in 99% of the case to be cause by Permalinks. Just by matching the Url in the browser and the setting of your Permalinks under WordPress–Settings>>>Permalinks, should fix the error.

Using WP-CLI to check your wordpress core integrity

A very useful trick to check your wordpress core integrity with wp-cli.
wp core verify-checksums – Verify WordPress files against WordPress.org’s checksums.

# Verify checksums
$ wp core verify-checksums
Success: WordPress install verifies against checksums.

# Verify checksums for given WordPress version
$ wp core verify-checksums –version=4.0
Success: WordPress install verifies against checksums.

# Verify checksums for given locale
$ wp core verify-checksums –locale=en_US
Success: WordPress install verifies against checksums.

# Verify checksums for given locale
$ wp core verify-checksums --locale=ja
Warning: File doesn't verify against checksum: wp-includes/version.php
Warning: File doesn't verify against checksum: readme.html
Warning: File doesn't verify against checksum: wp-config-sample.php
Error: WordPress install doesn't verify against checksums.
GLOBAL PARAMETERS
--path= Path to the WordPress files.
--ssh=[@][:][]
Perform operation against a remote server over SSH.
--http=
Perform operation against a remote WordPress install over HTTP.
--url=
Pretend request came from given URL. In multisite, this argument is how the target site is specified.
--user=
Set the WordPress user.
--skip-plugins[=]
Skip loading all or some plugins. Note: mu-plugins are still loaded.
--skip-themes[=]
Skip loading all or some themes.
--skip-packages
Skip loading all installed packages.
--require= Load PHP file before running the command (may be used more than once).
--[no-]color
Whether to colorize the output.
--debug[=]
Show all PHP errors; add verbosity to WP-CLI bootstrap.
--prompt
Prompt the user to enter values for all command arguments.
--quiet
Suppress informational messages.

Learn more here wp-cli doc