Woocommerce – How to delete all products

While developing a series of websites using the great Woocommerce for WordPress the development process we’re using at kc web design kent meant we needed to make copies of existing website designs and then redevelop them into new websites. Part of the process we went through at kc web design kent was changing the design and then adding a different set of products but to do this we first have to delete the existing ones. Adding products in Woocommerce is made very easy with the CSV import suite and updating existing products using a merge CSV import but there is no easy way to delete all products, especially when there are thousands of them. A nice feature in Woocommerce would be a way to bulk delete products but until that appears in the core or until someone makes a plugin the only way to delete products on-mass is to do it directly on the database.

Working directly on the database is always a bit scary, especially if you don’t know MySQL syntax and how to write complicated queries. Because of the way Woocommerce uses posts to store product data and the fact that products can have variations and custom post types, it can make it very difficult to know where all the data is stored. Woocommerce spreads the product data across posts, terms, taxonomies, term_relationships and post meta which makes things tricky if you want to do it in a visual SQL client. The best way is to use a few SQL queries. On this recent project at kc web design kent we needed to delete a lot of products and so after a bit of searching around on Google we came up with these queries.

Before using these remember to backup your database in case anything goes wrong. You’ll also need to change the default table prefix (wp_) to whatever you have used in your database. And remember, its always good practice not to use the default wp_ prefix on any WordPress websites. The queries below also have to be run in this order.

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');

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

Paul Ledbrook

If you have a new project or existing website that needs improvement, email us or call 0845 3631162 , we’d love to hear from you.

What’s new?

Latest Inspiring Web Design Trends And Techniques For 2024

The web design landscape for 2024 is set to be a dynamic and revolutionary one, with a blend of evolutionary and reactionary trends. From sci-fi-inspired design to adaptive headers and teleprompter typography, the upcoming year will witness a diverse range of innovative approaches. Additionally, bold and experimental typography, dark mode design, 3D elements, virtual reality...

The Unrivaled Excellence of our Web Design Agency Canterbury

Unveiling the Best Web Design Agency Canterbury In the bustling digital landscape, where every business vies for online supremacy, only a select few ascend to the zenith. Canterbury, a city steeped in history, is also home to unrivaled web design excellence. A top-rated web design agency Canterbury, kc web design Ltd, has been a beacon...

10 Things to Consider When Designing a High-Converting web app UI design

Your web app’s user interface (UI) is the first thing that users will see and interact with, so it’s important to make a good impression. A well-designed web app UI design can help you attract and retain users, and even increase conversions. Here are 10 things to consider when designing a high-converting web app UI...

How to Use Web Design to Improve User Experience

Introduction Your website is your online storefront. It’s the first impression that potential customers will have of your business, so it’s important to make sure it’s designed in a way that is user-friendly and easy to navigate. Good web design can help you improve your user experience (UX) in a number of ways. It can...

We’ve been featured on The Best Music Website Designs by DesignRush

A huge thank you to the guys at DesignRush for featuring the website design work we did with Go To Hear on their ‘Best Music Website Designs’ feature. Head over to the Best Design Trends page now to see our designs along with all the other fantastic music website designs. If you want to read...

SEO for web design – How to Optimise Your Website for Search Engines

Search engine optimisation SEO for web design is crucial for any business with an online presence. Optimising your website for search engines can increase its visibility, drive more traffic, and boost conversions. Follow these tips to make your website more discoverable and rank higher in search results: Choose the Right Keywords for SEO for web...

Website Design – 10 Things to Consider When Planning Website

What are the most important things to consider when designing a website? In today’s digital age, having a website is no longer optional; it’s a necessity. Research reveals that businesses without a website risk losing 70-80% of potential customers. Therefore, creating a well-designed and engaging website design is the crucial first step. But how can...

The Power of Professional WordPress Website Design Services for Business Success

In today’s digital age, a well-designed website is crucial for establishing a strong online presence. This is where our professional WordPress website design services and e-commerce website design shine. With our expertise in web design and development, our WordPress website design services play a pivotal role in helping your business create captivating online experiences that...

How-to create an effective E-commerce website design for online stores

Introduction: Understanding the Significance of E-commerce Website Design In today’s digital landscape, the design of an e-commerce website plays a pivotal role in shaping the success of online businesses. A well-crafted website design can significantly impact user experience, conversion rates, and overall brand image. By implementing effective design strategies, businesses can create visually appealing and...