Giter Site home page Giter Site logo

ag7-alexis / woocommerce-archive-orders-table Goto Github PK

View Code? Open in Web Editor NEW

This project forked from woocart/woocommerce-archive-orders-table

0.0 1.0 0.0 1.71 MB

This plugin can be used to archive orders older than 30 days to a separate orders table which helps to improve store's performance.

License: GNU General Public License v3.0

PHP 95.09% Shell 4.91%

woocommerce-archive-orders-table's Introduction

WooCommerce Archive Orders Table

This plugin can be used to archive orders older than 30 days to a separate orders table which helps to improve store's performance. There is absolutely no difference in how archived orders are displayed or accessed. However, the plugins relying on orders meta data won't be able to access data for the archived orders.

This plugin is based on LiquidWeb's Custom Orders Table.

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 five 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

Options

--duration=<no-of-days>
Set the duration of days, starting today, to skip archiving of orders.
For Ex: Setting this value to 45 will skip orders for the last 45 days from archiving.

Analysing extra meta keys added by plugins

The first step in the migration process is to analyse the extra meta keys added by the plugins based on which additional columns are created in the orders table.

$ wp wc orders-table optimize

Creating columns in the table for additional meta keys

The populate command creates the additional columns in the database to accomodate data for the additional meta keys associated with the orders data.

$ wp wc orders-table populate

Migrate order data from post meta to the orders table

The migrate command will flatten all 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

--batch-size=<size>
The number of orders to process in each batch. Default is 100 orders per batch.
Passing `--batch-size=0` will disable batching.
--duration=<no-of-days>
Set the duration of days, starting today, to skip archiving of orders.
For Ex: Setting this value to 45 will skip orders for the last 45 days from archiving.
--save-post-meta
Preserve the original post meta after a successful migration. Default behavior is to clean up post meta.

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

--batch-size=<size>
The number of orders to process in each batch. Default is 100 orders per batch.
Passing `--batch-size=0` will disable batching.

woocommerce-archive-orders-table's People

Contributors

stevegrunwell avatar bswatson avatar coenjacobs avatar dz0ny avatar lukecav avatar pmgarman avatar akshitsethi avatar boogah avatar dmurko avatar szepeviktor avatar alchemyunited avatar schlessera avatar ranss avatar crstauf avatar jb510 avatar uvlabs avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.