WooCommerce Database Schema Explained: How It Works and Where To Find It?
The term database is commonly used and understood by Billions of People, although a significant minority of people have it in their lexicon without understanding what it refers to.
Databases are at the foundation of so many digital services nowadays that it is easy to dismiss them totally, but whether you manage a retail website or a company server, understanding them is vital regardless of whether or not you are directly responsible for administrative chores.
It is essential to understand a database and its working procedure, especially if you’re managing a WooCommerce site and want to make the most of what this platform offers.
In this blog, we will explain everything necessary about WooCommerce Database Schema, Data Structure & Storage, how WooCommerce schema works, and where all the WooCommerce Structured data gets stored in the WordPress Database.
However, it’s a fair warning that this blog has some technical parts and some code-related terms that may require an advanced understanding of PHP and WordPress development. Anyhow, without further ado, let’s get along with today’s topic.
What Is Database?
A database is a system that stores information in an orderly manner, allowing details to be added, accessed, and amended as needed by an overall management system.
Order and efficiency are accomplished by organizing data into tables, with rows and columns allowing information to be structured logically, in a way that is both straightforward for human users to grasp and simple for software to work with.
SQL is not the only programming language on the market, but it is the most commonly used in database applications. The database is ideal for storing data for websites and housing materials such as media files, business papers, and everything in between.
Of course, any system that plays such vital roles in the digital era must be monitored and maintained to ensure that it functions properly. Performance might suffer due to blocking and deadlocking, which occur when numerous processes try to access the same resource simultaneously.
Maintaining data integrity with these features is essential, but administrators must also try to reduce the occurrence of such blunders. A poorly optimized database can have several unintended consequences, such as sluggish page load speeds for websites, which might increase bounce rates and decrease conversions.
WooCommerce Database Schema and Storage
Now that you have a basic understanding of databases, it is time to investigate their implications in WooCommerce. It is important to note that WooCommerce’s stored data of customers is not centralized; somewhat, this information can be scattered among tables built for the platform itself or based on the exact solutions as all WordPress sites.
Unless you make any modifications, WooCommerce will automatically correlate customer data with orders placed in your store. This applies to the customers who have created an account or choose to checkout as guests.
This all sounds wonderful in theory, but it means that multiple versions of the same customer data might exist in your site’s database because each order they place will replicate that. It may not be the most efficient method. Still, you can record and ensure all the advantages it offers, and every detail changes individually, which is helpful if the delivery address changes.
Similarly, you can create a WordPress user account and store that after placing your order. The wp_users table keeps information such as their email address, and the wp_usermeta table handles their shipping details.
Plugins like WooCommerce add a slew of new tables to the database designed to provide useful functionality to website administrators. Let’s look at how these custom tables work and their functionalities.
|actionscheduler_actions||To complete a list of functions ‘Action Scheduler’ function is used.|
|actionscheduler_logs||Actions completed by ‘Action Scheduler’ are stored at ‘Action Scheduler Logs.’|
|woocommerce_sessions||Contains the consumer’s cart.|
|woocommerce_api_keys||API keys storage.|
|woocommerce_attribute_taxonomies||Categories, tags, etc.|
|woocommerce_downloadable_product_permissions||Downloads access permissions.|
|woocommerce_order_items||Line items linked to orders.|
|woocommerce_order_itemmeta||Line items meta-data.|
|woocommerce_tax_rates||Manual setup of tax rate list.|
|woocommerce_tax_rate_locations||Location-based tax rates data.|
|woocommerce_shipping_zones||List of custom shipping zones.|
|woocommerce_shipping_zone_locations||Shipping zones location.|
|woocommerce_shipping_zone_methods||Shipping methods for each zone.|
|woocommerce_payment_tokens||Payment tokens for WooCommerce.|
|woocommerce_payment_tokenmeta||Metadata of WooCommerce payment token.|
|wc_product_meta_lookup||Metadata of product’s lookup table. This function makes it quicker to search for products inside orders.|
|wc_reserved_stock||Reserved stock to ensure availability at checkout.|
WooCommerce Products and Orders in the WordPress Database
In the above table, you’ll see a couple of highlighted functions named woocommerce_order_items and woocommerce_order_itemmeta. Whenever you need to manipulate your WP database using PHPMyAdmin, you also have to use those two highlighted functions from the table as they contain all WooCommerce order data.
The problem is that you can store WooCommerce and orders in other WordPress tables. Here’s a brief rundown of the tables involved.
Find WooCommerce Products in the WP Database
WooCommerce product data can be found in the following tables:
- wc_product_meta_lookup (product ID or product_variation ID)
- wc_order_product_lookup (product ID or product_variation ID)
- posts (product ID or product_variation ID)
- postmeta (product or product_variation)
- posts (product ID or product_variation ID)
Find WooCommerce Orders in the WP Database
WooCommerce order data can be found in the following tables:
- posts (shop_order ID)
- postmeta (shop_order)
- comments (order_note)
When to Use the WordPress Database
The first step toward effective database leveraging while running an eCommerce site is understanding how to make the most of queries to get data effectively.
While evaluating orders, you may filter your search based on a specific timeframe, which is beneficial if you want to examine performance within a given schedule or locate a specific order later. This is also applicable to other variables, such as product weight.
Similarly, it’s an excellent opportunity to know how to export data from WooCommerce so that you can analyze and process it elsewhere, such as with spreadsheet tools. This can be useful for multiple purposes, including tax preparation and market research into your target demographic.
It will eventually pay to learn the fundamentals of SQL if you want to fully utilize a database for online shopping. Because this is one of the most approachable programming languages available, it should be straightforward.
How WooCommerce Data Gets Stored in the WordPress Database
WooCommerce stores its data in a combination of WordPress database tables and custom tables. However, WooCommerce lacks a specific table for storing customer data. You can keep customers’ data in many database tables, making retrieving this data difficult.
Furthermore, depending on whether the consumer is a visitor or a registered user, there are two different ways to get customer data:
- WordPress user data – this information is only available to registered WordPress users.
- Order-based customer data – this is the customer data that is saved for each order and is accessible to both visitors and registered users.
Order Based on WooCommerce Customer Data
WooCommerce maintains the client data as part of each order by default. A customer’s information is always linked to the order, regardless of whether they are registered users or visitors.
This implies that if a consumer places many orders without updating their personal information, each order will include a duplicate of their customer information. While this may result in duplicated data, it also enables various personal details (such as billing address or contact number) to be provided for each order independently.
You can store customers’ data using the following graphical illustration:
WordPress User Data
If you disable the “Guest checkout” option in WooCommerce, a WordPress user will be formed for each consumer. WooCommerce will store the customer data in the WordPress user tables in this scenario.
- wp_users – Contains general user information such as email address and date registered.
- wp_usermeta – Preferred billing/shipping data. WooCommerce records the order billing/shipping information as user meta. This information will be available for future orders and a faster checkout process.
The following image indicates how every customer data connects to the database:
Searching WooCommerce Database
When searching the WooCommerce database, there isn’t any single technique. You need to determine your database queries by looking at your requirements and the data you need to load and search. So, here are some aspects to consider:
- Does your WooCommerce configuration enable visitors or just registered users?
- Is it necessary to connect orders to consumer search results?
- Which fields are necessary for the result?
Searching Order Based Data
As previously stated, order-based customer data is available for both visitors and registered customers. As a result, if your store enables guest checkouts, we recommend utilizing this search method.
Searching WooCommerce User Data
When searching for WooCommerce user data, you need to look for the user meta instead of the order meta. Although the method might look identical, the WooCommerce database query in this scenario will be completely different.
Searching WooCommerce User Data with Users Insights
As you already know, even the most simple WooCommerce database search requires a complicated query. This is where Users Insights come into play. With the help of an advanced filter, you can quickly search the registered user data, such as billing/shipping address, number of orders, and lifetime value.
By utilizing users’ insights, the entire procedure of searching WooCommerce user data gets is as simple as loading the billing address into a custom field and creating a filter by city and order status.
Where Exactly WooCommerce Products Data Get Stored?
You can upload new WooCommerce products to your staging site and add them to the live site without disrupting other data, such as orders and transactions. Consequently, you must replicate the tables containing the WooCommerce product data.
WooCommerce Products are located basically on two tables:
- wp_posts table with a post_type product or product_variation,
- wp_postmeta table with the corresponding post_id by product. (the product ID)
The following table contains product types, categories, subcategories, tags, attributes, and all additional custom taxonomies for specific products:
The custom taxonomy product_type handles product types with the following default terms:
Since a new custom taxonomy called product_visibility is handled by WooCommerce 3+:
- The visibility of the product using the keywords exclude-from-search and exclude-from-catalog.
- Usage of the term “featured” to denote all the feature products.
- Usage of the term “Out of Stock” refers to stock status.
- The rating system with terms from rated-1 to rated-5.
One Specific Feature: Every product attribute is a custom taxonomy.
And if you don’t want to copy or overwrite any WooCommerce data on your live website, you can exclude all the prefixed tables of your site using woo_ and also the tables wp_posts and wp_postmeta.
Where WooCommerce’s product data get stored?
In the WordPress Database.
When you upload products to your WooCommerce store, do you need to purchase storage from WordPress?
No, you don’t. However, your product storage capacity depends on the hosting plan. If your storage gets filled with data, you need to upgrade your hosting plan. You don’t need to buy any storage from the WordPress database. All of your product’s data automatically gets stored in the WordPress database.
Is WooCommerce Free?
WooCommerce is a self-hosted open-source eCommerce platform. So, of course, the plugin itself is free. However, there are additional costs when your store gets bigger, and your business starts to grow with WooCommerce.
WooCommerce product structured data is an integral part of the WordPress website. Because it contains all the information required to run a website, WooCommerce plugin developers need to understand how databases function and where to find the data.
However, we feel that all WooCommerece users should understand the fundamentals of the database because it is an essential component of their WooCommerce stores.
In this blog, we tried to cover and explain everything essential about the WooCommerce database schema, How it works, data storage, and many more. We hope that our blog will help you extend your knowledge of the WooCommerce database and customize your WooCommerce product schema.
However, if you still have any queries or confusion in this context, you can always reach out to us with your questions in the comment section. We promise that our experts will reply to all of your queries as soon as they see them. Thank you so much for giving us your valuable time and reading this blog.