I'm in the process of building a membership portal on this website (see here). As part of this, I've "had to" integrate OptimizeMentor** with WooCommerce. OptimizeMentor is software for online course and membership that I already own as part of the OptimizePress Suite.** It's great software with one big problem: it does NOT work with WooCommerce. Here's how I solved that...

First a quick clarification. Strictly speaking I didn't "have to" integrate the two. OptimizePress comes with its own payments system called OptimizeCheckouts,** and it's pretty good. However, it doesn't support as many payment gateways, and also doesn't integrate with my accounting provider.

I could also have chosen a different online course and membership plugin that supports WooCommerce out-of-the-box. There are multiple to choose from. All of them are rather expensive (on a yearly basis).

Given all of the above, I decided that the best path forward was to use OptimizeMentor with WooCommerce, and I "had to" integrate the two in order to achieve that.

How the Integration Works

Integrating the two systems is possible because OptimizeMentor has a web API. So, we can use a platform like Zapier to integrate the two. Here's how it works:

  • WooCommerce sends a message to Zapier that a subscription has been bought, ended, or changed. This triggers a Zap
  • The Zap calls the OptimizeMentor web API telling it to add/remove or update a membership accordingly

OptimizeMentor WooCommerce Integration Overview

The Integration Logic

We have two Zaps. One handles activation and deactivation of memberships, while the other handles membership tier changes. These are best understood pictorially (see below).

Zap1 overview Zap2 overviewAs you can see, the first five steps of both zaps are the same. They fetch the buyer's email address (step 2), and map the subscription's SKU number to the membership tier's ID (step 5). The first zap will then tell OptimizeMentor to add or remove a user to/from a membership tier depending on whether the subscription was activated or deactivated. Zap two adds the user to the new membership tier (step 6), and removes the user from the old tier (step 7).

This is what we need to build.


Here's what you'll need:

Building the Integration

I recommend watching the video (above) for step-by-step instructions. Here's a summary of the steps:

First, go buy the necessary plugins, and create a Zapier subscription. Next, create a test "variable subscription" product on your website, and add the appropriate membership tiers as variations. Make sure you enable it, and mark it as a "virtual' product (i.e., a product that doesn't get shipped). Each tier should have its own unique SKU number.

In the product listing's "Advanced" tab, set the "limit subscription" option to ""Limit to one active subscription". This is very important, because our integration will only work if a customer can only have one subscription at a time.

Now create the membership tiers in OptimizeMentor, and note the membership IDs for each tier (you're going to need it later).

Next, do a test purchase, and also a test membership upgrade/downgrade. This is so that Zapier has test data to work with when you're setting up the zaps.

NOTE: I highly recommend you test it on a staging website first so that it doesn't interfere with your public website. You can set the Stripe payment gateway to "test mode," and use fake credit cards instead of spending real money.

Zap 1 - Subscribers WooCommerce => OptimizeMentor

In Zapier, create a lookup table (you'll find the lookup table template at the bottom of the list of table types). Your table should have three columns: Key, Membership ID, Other Membership IDs. Fill in the table's rows with the appropriate data (e.g., see below). Give the table a useful name such as "SKUToMemebrshipID."

IMPORTANT: Make sure you don't add spaces to the "Other Membership IDs" entries. These will be passed in an API call URL, and spaces will cause it to fail.

SKUToMembershipID Table

Now create a new zap, with WooCommerce as trigger. You'll have to connect it to your WooCommerce store (see the WooCommerce Zapier plugin's documentation). Set it to trigger on a "Subscription satus changed" event. Call the Zap "Subscribers WooCommerce => OptimizeMentor."

Create the rest of the zap according to the following formula:

  • Step 2: WooCommerce
    Name this step: Lookup Customer Email
    action: "Find Customer"
    Set Customer ID to {1:Customer ID} (i.e., read the customer ID from step 1)
    Set role to "all"
  • Step 3: Filter by Zapier
    Name: "Skip if there are no line item SKUs"
    Only continue if {1. Line Items Sku} exists
  • Step 4: Create loop from line items
    Values to loop: name: SKU, value: {1. Line items Sku}
  • Step 5: Zapier Tables
    Name this step: Lookup Membership ID
    Action "Find record in table"
    Lookup field: "Key"
    Lookup value: {3. SKU} from previous step
    Set "should this step be considered a "success" when nothing is found" to true
  • Step 6: Paths
    • Path A
      • Step 7: Path Rule: {1: Status} exactly matches "active", and {5. Membership ID} exists
      • Step 8: Webhooks by Zapier
        Name: Add membership
        Action: POST
        URL: https://{base-url}/members?memberships={5:Membership ID}&opm_api_key={api-key}
        Data: email: {3: Email}
        IMPORTANT: Do NOT use billing email
        • See Mentor -> Settings -> API settings on your website for the base-url and api-key
        • After testing, check to see if the membership has been added in OptimizeMentor
    • Path B
      • Step 9: Path Rule: {1. Status} is in "cancelled, on-hold, expired", and {5. Membership ID} exists
      • Step 10: Webhooks by Zapier
        Name: Remove membership
        Action: POST
        URL: https://{base-url}/members/remove-membership?membership_id={5:Membership ID}&opm_api_key={api-key}
        Data: email: {3: Email}
        IMPORTANT: Do NOT use billing email

That's zap one done.

Zap one can be used as a starting point for zap two, because the first five steps are identical. So, create a copy of zap one, and call the new copy "Subscription Level Change WooCommerce => OptimizeMentor."

Now move the "Add membership" step (step 8) to just below step 5, and move the "Remove membership" step (step 10) to just above step 6. Remove steps 6, 7, & 8 (i.e., the path step). You should now have a seven step zap, with "Remove membership" as the last step. The "Add membership" step remains the same. Only the "Remove membership" step (now step 7) needs to be changed. Change it to the following:

  • Step 7: Webhooks by Zapier
    Name: Remove Old Memberships
    Action: POST
    URL: http://{base-url}/members/remove-membership?memberships={5:Other Membership IDs}&opm_api_key={api-key}
    Data: email: {3: Email} IMPORTANT: Do NOT use billing email

NOTE: The bits that changed are in bold. Everything else remains the same.

Final Steps

Congratulations. If you followed the steps above correctly, then you have successfully integrated OptimizeMentor with WooCommerce. One final step: publish/activate the two zaps so that they're ready for action. Now you can move on and build your membership portal and online courses.

What About One Time Course Purchases?

If you want to sell courses with one time purchases instead of subscriptions, then you'll need to build a zap (or zaps) with a different trigger. I haven't done this myself because I don't need it yet, but here's how it would be done:

  • The zap would need to be triggered by order status changes instead of subscription status changes
  • Each course would have its own membership in OptimizeMentor for access to a single course
  • One time purchases of courses would need their own SKU numbers, which would need to be included in the SKUToMembershipID table. The Other Membership IDs column would be empty for one time purchases, because there would be only one tier for the online course
  • The zap would choose path A or B depending on whether the order is paid, cancelled, refunded, etc.

Where's the New Membership Portal?

It's called the Kea Campus, and you can learn more about it by clicking here.


** Disclaimer: Some product links (above) are affiliate links, which we'll receive a small commission if you buy something.