Nicola Mustone

Happiness Lead @ Automattic



WC CLI Overview

In WooCommerce 2.5, the developers added support for WC CLI, which means that you can manage your WooCommerce store from the command line.

If you are familiar with WP-CLI, you know what I’m talking about. If not, keep reading, and I’ll show you how deep the rabbit hole goes.

WP and WC CLI

WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.

This is the description of WP-CLI on its website. WC CLI is exactly the same, but it works with WooCommerce only.
By using it, you can manage your store. You can do many things, like managing products, orders, coupons, customers, etc… all from your terminal.

If you are a Linux or OS X user, you will probably love this, unfortunately, Windows users never use the command line that much, so maybe you do not know how powerful can be this feature.

Here is an example of what it can do.

Using WC CLI for Development

Let’s say that I’m creating a new website for a customer. I have a list of products to add in a CSV format.

If I do not use WP and WC CLI, I have to:

  1. Manually download and install WordPress (10 minutes)
  2. Install and activate plugins and theme (5 minutes)
  3. Create every single product manually or import them with a plugin (can be days)

If I use WP and WC CLI instead:

  1. Download and install WordPress via the command line (2 minutes)
  2. Install and activate plugins and theme via the command line (2 minutes)
  3. Create products via command line (can’t be calculated exactly, but not days)

As you can see, creating a website via the command line is faster than doing it manually. Why?
Well, a computer is surely faster than a human.

With 3 commands (if well written), you can create a website in 10 minutes, with all the products included.

Another example, I want to delete all the orders in my staging site. If I do not use WC CLI, I have to:

  1. Go to WooCommerce > Orders
  2. Select all the orders on the first page
  3. Bulk delete them
  4. Repeat the steps 2 and 3 until all the orders are deleted

If I use WC CLI instead:

  1. Open the terminal
  2. Run a command

Also, in this example, you need fewer steps to delete all the orders and less time. Deleting an order via the command line takes about 1 second, so deleting 60 orders will take about 1 minute. Deleting them manually will take longer, depending on how fast you and your website are.

Also, you need to stay at your computer and keep deleting orders. With a command in the terminal instead, once you run it, you can go out and get a coffee, nap, or whatever you want; you don’t need to stay at your computer. The command line will do all the work alone.

Can I Use WC CLI on Any Website?

No, you can’t.

You need access to the command line; not all hosting gives you access. Only some do, like SiteGround or if you are on a VPS or a dedicated server. They call it Shell access or SSH. By connecting via SSH, you connect to the command line of your website, and from there, you can run commands. Also, WP-CLI has to be installed since WC CLI is built upon it.

If you are developing locally, you can install WP-CLI by yourself and use it, but on a host this is not always allowed, so check with your hosting if you have SSH access and if you can use WP-CLI with it.


Subscribe to This Blog

Receive new articles from this blog directly in your inbox! No spam guaranteed!

Join 670 other subscribers

Leave a Reply

You Might Also Like These Articles


Contribute to Improving This Blog

Did you enjoy this article? Was it helpful? Contribute to help me write more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

€1.00
€5.00
€10.00
€5.00
€15.00
€100.00
€5.00
€15.00
€100.00

Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

Don't Miss a Thing!

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 670 other subscribers

Continue Reading

Discover more from Nicola Mustone

Subscribe now to keep reading and get access to the full archive.

Continue reading