woocommerce-custom-orders-table

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

Github星跟蹤圖

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.

主要指標

概覽
名稱與所有者liquidweb/woocommerce-custom-orders-table
主編程語言PHP
編程語言PHP (語言數: 2)
平台
許可證GNU General Public License v3.0
所有者活动
創建於2017-09-29 19:01:30
推送於2022-06-14 19:25:02
最后一次提交2021-07-13 11:11:09
發布數6
最新版本名稱v1.0.0-rc3 (發布於 2019-07-24 15:29:46)
第一版名稱v1.0.0-beta.1 (發布於 )
用户参与
星數474
關注者數65
派生數50
提交數560
已啟用問題?
問題數107
打開的問題數0
拉請求數71
打開的拉請求數0
關閉的拉請求數13
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?