Skip to content
site logo mobile

SaaS on WordPress: Setup Credit System!

Table of Contents

Today, you will learn how to set up a SaaS on WordPress with the credits system.

Just like mine here! Users can buy points and use my tools.

What is SaaS?

Since you are here, I think you already know what SaaS is.

But just in case, SaaS stands for Software as a Service.

It’s a method of providing services online without the inconvenience of installing and maintaining software on your hardware.

Users can simply access the service online without having to deal with software and hardware implications.

So, with SaaS, you’re simply renting a tool online for as long as you’re subscribed. This ‘tool’ is typically software that provides specific services.

In simple terms, building a SaaS on WordPress means we are making a tool or service that people can use online through our WordPress website. They can either pay for a subscription or use a credit system, just like we are gonna in this post.

Plugins For SaaS

Plugins make our life a lot easier!

Let’s explore some plugins that will be the backbone of our SaaS on WordPress.

WooCommerce:

WooCommerce transforms your WordPress website into a fully functional Online store.

Usage in Our SaaS:

We will primarily use WooCommerce for selling points, but you can also sell products or services.

WP Code Snippet:

WP Code Snippets allows you to add and manage custom code snippets easily to your WordPress site.

Why Snippets?

It’s essential for adding custom functionalities specific to your SaaS requirements.

MyCred:

myCred is an adaptable points management system that allows you to build and manage a credit-based system easily on your WordPress site.

Plugin Installation (for beginners):

To download the plugins, just open your WordPress dashboard and navigate to the plugins section as shown in the picture below:

install wordpress plugins

Search for the plugins, install and activate them, and we are set!

saas on wordpress plugins.png

To get a feel of how it does myCred, you can navigate to the user’s section in the dashboard and click edit on the user, where you can adjust the points of each user, adding or subtracting.

mycred points

What we are mainly trying to do here is to automate the process of adding (when buying) or subtracting (when using our service or tool) so that each time the tool is used, the points or credits will be consumed.

Building The Tool

Building Tools on WordPress is out of scope in the post, as I already created a blog post and explained step by step how to Create an AI tool on WordPress. You can check it out.

If you have already created a tool, you can skip this section; if not, hop into that article, build your tool, and then you can continue the implementation. Or just follow up to see how the SaaS system works in WordPress, and then you can take action!

In short, Creating tools on WordPress involves 3 main steps.

Create a WordPress Page

Start by creating a new page on your WordPress site hosting the AI tool. This page will be the user interface for interacting with the tool.

Add HTML Code

Add Some HTML code to create the tool page.

Implement a WordPress Function:

You’ll add a custom WordPress function that receives the user input from the HTML form and processes it.

build tool on wordpress

When the user interacts with the tool, a JavaScript script runs in the background and connects with a Snippet in our WordPress backend.

WordPress Credit System

Here is where the real magic begins!

We will see how to implement a Credit system on WordPress or what I call a Points system.

Users can buy points, consume them when using tools, and then buy again!

It is like any credit system out there but on WordPress!

Credit System on WordPress

Step 1: Create the Product

First, head to WooCommerce and start by creating a new product. Think of this as setting up a points package. Fill in details like the product name and description, and add a nice picture, maybe like this:

wordpress credit system

Next, make sure to check the box that allows users to earn points when they buy this package. You’ll also set how many points they get, like 50, 100, or 1000, depending on your pricing.

With this setup, users can buy points and see their balance go up!

Step 2: Check User Balance When Using Tools

Once your points system is set up, the next step is to ensure that users have enough points to use specific tools.

For instance, let’s say a tool requires 7 points for usage.

Here’s where WP Code Snippets come into play.

Simply open the tool’s code or function and integrate the following code to check the user’s point balance. If the balance is sufficient, proceed with tool access. Otherwise, return a message indicating insufficient points.

    // check for balance
    $user_id = get_current_user_id();
    $balance = mycred_get_users_balance($user_id);
    if ($balance < 5) {
		wp_send_json("NO_BALANCE");
    }

The Function will look like this:

mycred check user balance

Remember, here, we assumed that you already created a tool following this guide.

Step 3: Deducting Points When Using Tools

After the user has used a tool, it’s essential to deduct the appropriate number of points.

Add a simple line of code to deduct points before returning the response to the user.

mycred_subtract("Tool name", $user_id, 5, 'Point deduction for using tool name', time());

Make sure to change “5” to the number of points you want to deduct.

You will need to add this line directly before returning the results here:

mycred deduct points

In this image, I am showing you the code when users use my Hook Generator Tool

In summary, with this system in place, users can purchase points, utilize tools, and have their points deducted accordingly. This functionality mirrors typical SaaS credit systems but is seamlessly integrated within WordPress.

If you liked this idea, and you want to go more in-depth and see the secrets behind my Points system, and go step by step and access our private discord server and forums, you can check my full course here.

3 thoughts on “SaaS on WordPress: Setup Credit System!”

  1. Is there any way to use the credit system with other tools?
    I have chatbots functioning as custom gpts, embedded into different pages
    so same idea but not using functions to get info from chatgpt
    Love the credit idea for allowing access to the gpts if it’s possible..

    Thanks!

    1. Hasan Aboul Hasan

      Yes, mycred has an api, so theoritically you can connect GPT with the API and check for balance, and then users can buy credits to use the GPT

Leave a Reply

Your email address will not be published. Required fields are marked *