WooCommerce / Sample Implementation

Discover how to easily configure Wordpress to connect to our API

1/Setup your Server

A basic configuration to unleash your webshop.

2/Install WooCommerce

Enable needed features for WooCommerce

3/Install WP-AllImport

Setup the import plugin

4/Update the stock

Enable fast-stock refresh

Install Wordpress and Woocommerce

Prerequisites

This page assumes that your server in configured as described on this page. If not, you can use the following documentation as to setup your own install.

 

Install Wordpress

Get the installation files an copy them to the correct folder

$ wget https://wordpress.org/latest.zip
$ sudo mkdir /var/www/wordpress
$ sudo apt install unzip
$ sudo unzip latest.zip
$ sudo mv wordpress/ /var/www/wordpress

Log into the database manager to create the Wordpres database

$ sudo mariadb -u root

This launches the SQL interface. Type the following commands to create a database named wordpress with an authorized user named wpuser having your-password as password

> CREATE DATABASE wordpress;
> CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your-password';
> grant all privileges on wordpress.* to wpuser@localhost identified by 'your-password';
> flush privileges;
> exit;

Configure Wordpress

Copy the standard wordpress configuration file

$ cd /var/www/wordpress
$ cp wp-config-sample.php wp-config.php
$ sudo nano wp-config.php

Edit the file to connect correctly to the DB :

define(‘DB_NAME’,’wordpress’);
define(‘DB_USER,’wpuser’);
define(‘DB_PASSWORD’,’your-password’);

Finally, correctly set the rights on the folder

$ sudo chown www-data:www-data /var/www/wordpress/ -R

Configure Apache Virtual Hosts

The following assumes:

1. That you have a DNS (wordpress.example.com) pointing to your server (XXX.XXX.XXX.XXX)

2. That you have a Security Certificate located at /certificates/cert.pem – this one is optional and will enable https on your website. Yet there is no such good reason as not to SSL Encrypt a server.

Run the following command to create a configuration file for the HTTP host

$ sudo nano /etc/apache2/sites-available/wordpress.conf

Then create your virtual host. You can Copy/Paste the following sample and tune it to your needs.

DocumentRoot must match the installation folder of your wordpress.

<VirtualHost *:80>
    ServerName wordpress.example.com
    DocumentRoot /var/www/wordpress
        <Directory "/var/www/wordpress">
        AllowOverride All
        </Directory>

    ErrorLog ${APACHE_LOG_DIR}/wordpress.error.log
    CustomLog ${APACHE_LOG_DIR}/wordpress.error.log combined
</VirtualHost>

Run the following command to create an configuration file for the HTTPS host. This is optional but highly recommended for your customers, and mandatory if you wish to connect without any issue to our API.

$ sudo nano /etc/apache2/sites-available/wordpress-ssl.conf

Then create your virtual host. You can Copy/Paste the following sample and tune it to your needs. DocumentRoot must match the installation folder of your wordpress. SSLCipherSuite directive must be on on line.

<VirtualHost *:443>
    ServerName wordpress.example.com
    DocumentRoot /var/www/wordpress

# Enabling SSL
    SSLEngine On
    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off
    SSLProtocol all -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS"
    Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"

    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule ^(.*)$ $1 [R=200,L]
    SSLCompression Off
    SSLCertificateFile /path_to_your_certificate/certificate.pem

    <Directory "/var/www/wordpress">
    AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/wordpress.error.log
    CustomLog ${APACHE_LOG_DIR}/wordpress.error.log combined
</VirtualHost>

Once done, check if you didn’t make any syntax error

$ sudo apache2ctl configtest

This should return “Syntax OK”. If yes, enable both sites and restart the Apache2 service

$ sudo a2ensite wordpress.conf
$ sudo a2ensite wordpress-ssl.conf
$ sudo service apache2 restart

First launch

Visit the Wordpress installer at https://wordpress.example.com/wp-admin in a web-browser (replace with your domain). The first screens asks you to select the default language:


Then you need to create an Administrator account. Do not loose the credentials.


Finally, login to Wordpress Backend with the credentials you just set.




Install the WooCommerce Plugin

Go to “Plugins > Add New” and search for “WooCommerce”


 

Once found, click on “Install” then on “Activate”. This will guide you to the WooCommerce Setup Wizard. Answer all the questions as per your needs – you can change everything afterwards.