Wordpress, an open-source content management system (CMS) written in PHP, plays a dominant role in the internet nowadays. Different sources quote WordPress market share to be around 35% of all websites. Its not a surprise then that Woocommerce, an open-source e-commerce plugin for WordPress is the most popular CMS used by merchants to take their shops to the online world.

When developing services and solutions, integration of these with the Wordpress ecosystem is therefore a very important task, as it opens the door to a very large customer base. The goal of the AWS Marketplace developer Challenge is to use a Machine Learning (ML) model from the AWS Marketplace in innovative and relevant solutions. I will use of the AWS Marketplace to provide a practical solution that helps online merchants increase their sales and improve the relationship with their customers.

The objective of my project is to integrate a ML model from the AWS Marketplace with Woocommerce. I will use the Mphasis HyperGraf Market Basket Analysis model. This model is capable of providing product recommendations based on previous customer purchase history, extracting relations among products that are frequently bought together.

This solution can bring direct benefits to online merchants in the form of additional revenue, higher average basket sizes, and more satisfied customers. The role of product recommendations in E-commerce should be known to anyone that has bought products from Amazon for instance. See here for a nice review of the development of Amazon recommendation engine. The idea of my project is therefore to provide product recommendations as a service to small and medium size merchants, automatizing the task of cross-selling for online merchants and extracting insights from historical data with the use of Machine Learning methods.

Looking beyond, integrating machine learning services built with the AWS infrastructure into the popular CMS used by online merchants (such as WordPress/Woocommerce) can give many benefits to small and medium size merchants so is an avenue worth exploring.

What it does

The model uncovers associations between articles and identifies the frequent products which are likely to be purchased together. These associations among products can be used to power product recommendations (cross-sells) in product detail pages, checkout pages, email campaigns, etc.

The pipeline built in this project starts by fetching transactional data from any Woocommerce Shop using the Woocommerce Rest API, then moves the data to an S3 bucket. The AWS Sagemaker Batch Transform Job retrieves this data from the S3 bucket and uses it to train a Mphasis HyperGraf Market Basket Analysis model from the AWS Marketplace. The model outputs product recommendations based on patterns extracted from previous customer purchases. These recommendations can be used in the online shop for cross-selling purposes. In order to integrate these recommendations to the online shop, we use the Woocommerce Rest API to upload the recommendations to the MySql database of WordPress.

After running the full notebook, we will have populated the 'cross_sell_ids' field of our MySql database (which is empty by default). Woocommerce already provides several options to visualize these product recommendations as sliders on Product or Checkout pages. This project therefore provides an automatization of cross-selling marketing for online merchants.

I used the following AWS services in this project:

  • Amazon Lightsail (to host the Woocommerce online shop)

  • S3 (to store data used in communication between the AWS marketplace model and the Woocommerce Rest API)

  • Amazon Sagemaker

  • AWS Marketplace

The architecture of the pipeline is the following:

Here are some example cross-selling recommendations that I generated:

How I built it

I used AWS Lightsail to deploy the Wordpress application (see here for a tutorial). It only takes 5 minutes to have an instance running with Wordpress. Installing the Woocommerce plugin can be done with few clicks from the Wordpress back-office (see these instructions for example). With these steps we have already set-up a fully fledged online shop. We can continue its customization by uploading our product inventory and using the rich set of plugins available from the Wordpress & Woocommerce communities (to add payment methods, change the frontend, etc).

Extracting data from our Woocommerce application (data is stored in a MySql database) I use python wrapper around the Woocommerce REST API. The required datasource used by the Mphasis HyperGraf Market Basket Analysis is stored in S3, as well as the output from the Batch Transform Job containing the product recommendations.

I upload the product recommendations using the Woocommerce Rest API into the 'cross_sell_ids' field of Woocommerce which is empty by default. This facilitates integration of these recommendations to the shop front-end, as they are internal Woocommerce fields and one can find plugins taking care of displaying those.

The batch transform job can be invoked from a CLI or from jupyter notebook. Please find the GitHub repository here. A Jupyter Notebook is also provided within the repository.

The online shop I set up for testing purposes using Amazon Lightsail was themed with plants and flowers, but of course the project is aimed at a generic integration with any Woocommerce shop. You can visit my test online shop.

Choosing between Model Batch Transform and Model Realtime Inference. For small and medium size merchants with online shops in Woocommerce, updating the recommendations doesn´t require a realtime inference endpoint, so a batch job is the preferred option.

What are the expected costs for the merchant? Using the pricing guidelines one has an estimate of $0.634 Total/hr using an ml.m5.large instance.

Challenges I ran into

A complete integration to the Woocommerce shop, though straightforward in principle has some subtleties when one wants to make it as seamless as possible for the merchant to integrate within their shops.

Accomplishments that I'm proud of

I am proud of achieving a full integration of the AWS marketplace model with an online Woocommerce shop. It can be used by merchants to automatize their cross-selling marketing efforts and achieve higher conversion rates.

An integration of AWS services with Wordpress/Woocommerce opens many opportunities for me and for everyone interested in continue developing along this direction. Creating high quality services for small and medium size merchants can be very rewarding, as they often dont have the possibility to access the IT resources needed to set up these services.

What I learned

I learned a lot about Wordpress/Woocommerce and about the AWS Sagemaker and AWS marketplace. Setting up an online shop from scratch and developing the solution I made was also a lot of fun. I learned also that there are still many possibilities open for providing high quality analytics services for small and medium size online merchants.

What's next for Cross-sell recommendations for E-commerce

I would say achieving a more seamless integration with the merchant shop is necessary, in the form of a Wordpress plugin which can be installed with a couple of clicks. Such plugin can also serve as an opportunity to provide customization of how the recommendations are displayed on the frontend .

Another important topic for me is to measure the uplift provided by the service, in order to quantify how valuable it is in terms of added revenues to the merchant.

Built With

Share this project: