woocommerce-custom-orders-table

Store WooCommerce order data in a custom table for improved performance.

Github stars Tracking Chart

WooCommerce Custom Orders Table

Build Status
Coverage Status

This plugin improves WooCommerce performance by introducing a custom table to hold all of the most common order information in a single, properly-indexed location.

Background

WooCommerce 3.0 introduced the notion of CRUD (Create, Read, Update, and Delete) interfaces in a move to unify the way WooCommerce data is stored and retrieved. However, orders are still stored as custom post types within WordPress, with each piece of order information (billing address, shipping address, taxes, totals, and more) being stored in post meta.

In fact, WooCommerce will typically create over 40 separate post meta entries for every single order. If your store receives even 10 orders a day, that means 400 new rows in the table every single day!

The larger the post meta table grows, the longer queries will take to execute, potentially slowing down queries (and thus page load times) for you and your visitors.

WooCommerce Custom Orders Table uses the WooCommerce CRUD design to save order data into a single, flat table that's optimized for WooCommerce queries; one order means only one new row, with minimal performance impact.

Requirements

WooCommerce Custom Orders Table requires WooCommerce 3.5.1 or newer.

If you're looking to migrate existing order data, you'll need to have the ability to run WP-CLI commands in your WooCommerce environment.

Migrating order data

After installing and activating the plugin, you'll need to migrate orders from post meta into the newly-created orders table.

The easiest way to accomplish this is via WP-CLI, and the plugin ships with three commands to help:

Counting the orders to be migrated

If you'd like to see the number of orders that have yet to be moved into the orders table, you can quickly retrieve this value with the count command:

$ wp wc orders-table count

Migrate order data from post meta to the orders table

The migrate command will flatten the most common post meta values for WooCommerce orders into a flat database table, optimized for performance.

$ wp wc orders-table migrate

Orders are queried in batches (determined via the --batch-size option) in order to reduce the memory footprint of the command (e.g. "only retrieve $size orders at a time"). Some environments may require a lower value than the default of 100.

Please note that migrate will delete the original order post meta rows after a successful migration. If you want to preserve these, include the --save-post-meta flag!

Options

Copying data from the orders table into post meta

If you require the post meta fields to be present (or are removing the custom orders table plugin), you may rollback the migration at any time with the backfill command.

$ wp wc orders-table backfill

This command does the opposite of migrate, looping through the orders table and saving each column into the corresponding post meta key. Be aware that this may dramatically increase the size of your post meta table!

Options

Contributing

If you're interested in contributing to the development of the plugin or need to report an issue, please see the contributing guidelines for the project.

Main metrics

Overview
Name With Ownerliquidweb/woocommerce-custom-orders-table
Primary LanguagePHP
Program languagePHP (Language Count: 2)
Platform
License:GNU General Public License v3.0
所有者活动
Created At2017-09-29 19:01:30
Pushed At2022-06-14 19:25:02
Last Commit At2021-07-13 11:11:09
Release Count6
Last Release Namev1.0.0-rc3 (Posted on 2019-07-24 15:29:46)
First Release Namev1.0.0-beta.1 (Posted on )
用户参与
Stargazers Count474
Watchers Count65
Fork Count50
Commits Count560
Has Issues Enabled
Issues Count107
Issue Open Count0
Pull Requests Count71
Pull Requests Open Count0
Pull Requests Close Count13
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private