With the current version of WooCommerce, the 2.5, the developers added the 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 thing, 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:
- Manually download and install WordPress (10 minutes)
- Install and activate plugins and theme (5 minutes)
- Create every single product manually, or importing them with a plugin (can be days)
If I use WP and WC CLI instead:
- Download and install WordPress via command-line (2 minutes)
- Install and activate plugins and theme via command-line (2 minutes)
- Create products via command-line (can’t be calculated exactly, but not days)
As you can see, creating a website via command-line is faster than doing it manually. Why?
Well, a computer is surely faster than a human.
With a total of 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:
- Go to WooCommerce > Orders
- Select all the orders in the first page
- Bulk delete them
- Repeat the steps 2 and 3 until all the orders are deleted
If I use WC CLI instead:
- Open the terminal
- Run a command
Also in this example, not only you need fewer steps to delete all the orders, but also less time. Deleting an order via command-line takes about 1 second, so deleting 60 orders will take about 1 minute. Deleting them manually will take definitely more, 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, take a nap, 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 to have access to the command-line and not all hosting give you access to that. 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 hosting this is not always allowed, so check with your hosting if you have SSH access and if you can use WP-CLI with it.
What’s Next?
This is just an overview of what WC CLI is and what it can do. I’ll write other posts about it, showing you how to do things. In the meantime, why don’t you take a look at the documentation?
Leave a Reply