Need a quick Woocommerce site?
WP-CLI to the rescue!
I need a quick Woocommerce site!
I have several clients that have been asking for promotional marketing materials, and I just so happen to have the vendor and payment gateway ready to rock, what I don’t have is a way for them to order without me being involved after the initial set up.
WP-CLI should help me get set up quickly!
Infrastructural Prerequisites:
Web Hosting - I have a CentOS server w/cPanel
I chose to log into the cPanel GUI for this portion.
You could make this happen pretty easily from the command line. MySQL tutorials galore - LMGTFY
CPanel: create database - set user / permissions
Required WP-CLI : if needed on web host (most come pre-installed depending on provider and setup), you can follow the instructions here: https://wp-cli.org/
// ssh into web_host
$ ssh web_host
// change directory into your web_root folder (public_html?)
$ cd web_root
// Make your subdomain directory and enter it
$ mkdir subdomain_folder
$ cd subdomain_folder
Here’s where the WP-CLI beauty takes place!
//Download Wordpress
$ wp core download
// Create a wp-config file using the database credentials you set up earlier
$ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd
// Install Wordpress with setup
$ wp core install --url=example.com --title=Example --admin_user=supervisor --admin_password=strongpassword --admin_email=info@example.com
Note on “Too Many Positional Arguments” error if more than one word title is entered. You must escape spaces and some special characters so the CLI does not thing you are trying to include another parameter/argument. Wrap the value in single or double quotes to parse space as part of the string.
Example:
$ wp core install --url=example.com --title='Example of multi word title wrapped in single quote' --admin_user=supervisor --admin_password=strongpassword --admin_email=info@example.com
I need a Simple theme, quick to customize, integrates with Woocommerce. I picked Flash Theme for being free to download and easy to customize with ready out-of-the-box Woocommerce support, and trusted Page Builder friendly integration.
// Install theme and activate
$ wp theme install flash --activate
CPanel: create subdomain - set root to subdomain_folder
Could do this in command line -> Google search for tutorials if you want? There are examples for days! - LMGTFY
Now, I have a fully functional lair of doom! bwhahaha.. Ok, not quite, but I have a hosted wordpress site and theme up in about 5-10 minutes.
Let us add on some minimal functional plugins. We’re here for a place where my clients can purchase marketing materials, after all.
$ wp plugin install woocommerce --activate
wp plugin install siteorigin-panels --actvate
NOTE - PLUGIN AND THEME INSTALLS CAN BE CHAINED
Now we can restrict items visible to users by role to separate out different client products by login. Essentially, we will be creating Password Protected Categories using custom user roles. See Catalog Visibility Options settings in woocommerce talked about here - Woocommerce Catalog Visibility
We can create a specific role for each customer, ar as your needs see fit!
$ wp role create customerName customerRole
To Start Selling y’all need:
Vendor Integration or Products - I have a Printful account that I use for print-on-demand drop shipping API integration. Works good for my needs. Not the greatest markup, but no overhead beyond setup!
Payment Processor - I use Stripe. It just works and the control panel with multi-site / identity options are great.
Finishing set up
You can now visit you new wordpress/woocommerce subdomain!
I will save the remainder of setting up the theme and woocommerce products for another date. All in all, it took about 10 minutes to get a wordpress site with woocommerce up and hosted, ready for integration. Not too shabby.
Highly recommend working all things wordpress with WP-CLI See Commands HERE