npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

order-fetcher

v4.0.0

Published

WooCommerce order fetcher

Downloads

99

Readme

order-fetcher

Retrieves WooComerce order information and displays it in your terminal or saves it as a CSV file.

npm version build status code coverage snyk vulnerabilities

Getting started

After installing order-fetcher (via npm install -g order-fetcher), you can run orders config init to create your initial configuration file. It will ask a bunch of questions to help get everything set up. You will need to make sure that the WooCommerce API is enabled, and that you have a key and secret defined. Because order-fetcher only ever retrieves data, and never makes changes to your site, it only requires read-only access.

The nickname you give your site allows you to disambiguate if you have more than one: orders host1 ... and orders host2 ... will retrieve data from either “host1” or “host2”, assuming those are the nicknames you gave. (But please, for your own sanity, use useful and memorable nicknames!)

If you don’t have too many historical orders on your site, your first request can be as simple as orders host1. If you have a lot of orders, however, that command can take a while. Using the --after option to only include orders on-or-after a particular date (like orders host1 --after 2019-07-01) can dramatically improve performance.

Usage

As of v1.0, order-fetcher now also installs as the command orders, and uses a more “subcommand”-style command-line (like git, npm, and other tools). It also uses the host nicknames (as defined above, in Getting Started) as subcommand shortcuts rather than the older and more-verbose --host hostname flag. Note that you can still use orders get --host host1 ... rather than orders host1 ..., but you’ll find that the newer second invocation is more natural and involves less typing.

When all else fails, orders --help (or order-fetcher --help) lists all of the available options.

Top-level commands/options

| command | description | | -------------------------- | ----------------------------------------------------------------- | | config | shows configuration information | | get (or host nickname) | retrieves orders from a WooCommerce site | | -v, --verbose | increase verbosity of logging output, can be given multiple times | | -h, --help | output usage information | | --version | output the version number |

config commands/options

| option | description | | ----------------------------- | ----------------------------------------------------------- | | init | interactive first-time configuration set up | | view | show current configuration | | add [host-nickname] | add a new WooCommerce host (interactive, like init) | | remove [host-nickname] | remove an existing WooCommerce host | | timezone (or tz) [zone] | change the timezone (interactive if zone is not provided) | | -h, --help | output usage information |

get (or host-nickname) options

| option | description | | -------------------------- | ------------------------------------------------------------------- | | --host host-nickname | WooCommerce host to use (only for orders get) | | --after date | include only orders after the date | | --before date | include only orders before the date | | --status status | include only orders with the given status | | --sku sku | filter to the specific sku, can be given multiple times (default: ) | | --sku-prefix skuPrefix | filter to the sku prefix, can be given multiple times (default: ) | | --list-skus | list the skus found in the orders | | --list-statuses | list the statuses found in the orders | | --list-columns | list the available columns found in the items | | --omit-blanks | omits columns where every item's value is blank or missing | | --omit-identical | omits columns where every item's value is identical | | --omit-payment | omits payment columns (including payer address and phone) | | --omit column | omits a specific column | | --include column | includes a specific column | | --columns column-list | selects an exact set of columns to display (comma-separated names) | | -o, --out filename | file to write (CSV format) |

Best practices

For WooCommerce installations with a large number of historical orders, making use of the --after options is highly recommended. Similarly, use --status processing to only include orders that haven't been handled yet. (And then mark those orders as "completed" as soon as you deal with them.)

When generating CSV output, the columns come directly from the item information in WooCommerce. More than likely, you'll want to use the --sku option to create CSV files on a sku-by-sku basis.

About column filtering

The various --omit... and --include options control whether columns are included or omitted in the output. As a rule of thumb, columns are included for CSV file output for consistency across invocations, and the --omit-... options are enabled by default for screen output to reduce line-wrapping. If you need to not omit columns for screen output, you can prefixthe option with no, as in --no-omit-identical.

If the --omit-... options are too coarse, you can enable or disable individual columns using the --include and --omit options, or for complete control use the --columns option to specify exactly what columns you want displayed and in what order they will appear. Using --list-columns will list all of the column names available. Do note that unless you use --columns to specify an exact set, the following columns are always included: "order#", "date", "name", "email", "qty", and "total".

Examples

orders host1 --after 2019-01-01 --status processing --list-skus

Retrieve all orders after 1 January 2019 (inclusive) with a status of "processing", and list the unique SKUs. This is useful as a precursor to creating per-SKU CSV files.

orders host1 --after 2019-01-01 --status processing --sku some-sku --out some-sku.csv

Retrieve all orders as in the previous command, filter the items to the SKU 'some-sku', and write to 'some-sku.csv'.