How To Build A Service Credit System On Your MemberMouse Membership Site

Last Updated on April 17, 2020  

What if you want people to be able to buy something on your MemberMouse membership site, store it as credits on their profile, then redeem them for a service at a later date?

This is what I needed inside THE LAB.

See, there are member services that people can optionally buy if they wish. For instance:

  • Coaching Calls
  • Technical Service

I wanted to be able to offer the ability to buy one-off services yet not force them to take advantage of it immediately. I also wanted to be able to offer packages where they could purchase multiple services at once. For instance, they could purchase 3 strategy calls at once and use them over time.

I also had an issue where I might run a special offer where I might throw in a strategy session as a bonus, or perhaps even a month of Platinum Coaching. This led to an issue of tracking.

How do we keep track of these service credits? Are we supposed to keep a spreadsheet and manually record what we owe people?

That's what we did in the past. But, it was unreliable. We would tell people to email us when they want to use one of their services, but this would rely on their memory. Sometimes our memory. Or looking back in conversation history in our support desk to seek proof of what we owed them.

So, I needed to find a better way.

And by using MemberMouse custom fields, I did find a better way.

Using MemberMouse Custom Fields For Service Credits

Inside of MemberMouse, under the Checkout Settings, you have the ability to set up custom fields. And I created 5 fields for storing credits for various services:

Obviously, I disabled the ability for members to edit these fields themselves since I am using them for internal purposes only. So now when I go into any member's profile and go to their custom fields, I can see these fields.

You can see here that this member currently has 4 credits for tech service and 3 credits for future coaching sessions. Fields with no credits can either be blank or 0.

Now, this setup gives flexibility. If I want to edit any member's credits, I just go into their profile and change the number. After I do a coaching session, for instance, part of my process is to go into their profile and remove 1 strategy call credit from their account.

The cool thing, too, is that now members themselves can see their credits. When they go to their Account screen inside the LAB, they will be able to see their credit balances.

There's no relying on memory here. It is all in the open. Plus, if they take advantage of an offer which bundles services as bonuses, they now have visual confirmation that we are actually delivering that and not relying on memory alone, or telling them to save an email receipt. Displaying credit balances is also a handy place to give them a call to action to purchase more credits.

But, what about the purchase side of it?

Can I automatically add credits to their account based on what product they purchased inside of MemberMouse?

Why yes. You can. 🙂

How To Add Credits To Their Account When They Make A Purchase

Now, fair warning. It gets geeky when you want to pull this off.

If you want to see about getting our help to implement this on your site, click here.

You will need to be able to work with PHP code directly to properly implement this on your own. Let's see if I can give you a head start, though. 🙂

The solution relies on 2 important facts about MemberMouse:

  1. MemberMouse has an API which can be used to do very custom operations using external scripts, then you sync the data back to MemberMouse using the API.
  2. MemberMouse  has action hooks (like all of WordPress) for various actions that take place. For instance, when a payment is received, a hook is executed.

This means that you can write a script which essentially does the following:

  1. Looks for any time a payment is received. Then...
  2. Looks at the product ID(s) being purchased. Then...
  3. Based on the product ID, adds the proper amount of credits to the appropriate custom field.
  4. Uses the API to save the credit information back to MemberMouse.

I created a PHP file that contains a number of functions specific to MemberMouse and I included that file into my theme. And here is the function that does the work we're talking about here:

function lab_servicecredits($data) {
global $apiurl,$apikey,$apipassword;
$products = json_decode(stripslashes($data["order_products"]));

$newcreditbalance = 0;

$inputParams = "apikey=".$apikey."&apisecret=".$apipassword."&";
$inputParams .= "member_id=".$data['member_id']."&";
$inputParams .= "email=".$data['email']."&";

if ($products[0]->id==47) {
// single tech service credit
$newcreditbalance = intval($data["cf_14"])+1;
$inputParams .= "custom_field_14=".$newcreditbalance."&";
}
if ($products[0]->id==90) {
// 3 tech service credits
$newcreditbalance = intval($data["cf_14"])+3;
$inputParams .= "custom_field_14=".$newcreditbalance."&";
}

$apiCallUrl = $apiurl."?q=/updateMember";
$ch = curl_init($apiCallUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $inputParams);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
}
add_action('mm_payment_received', 'lab_servicecredits');

Now, I didn't include everything here. And surely, you'll need to be adept with PHP to take it from here. But, here's the jist of it...

  • When the mm_payment_received hook is run, it will then run this function. And all the member and order data is automatically fed into this function.
  • Using some if statements, we run code on specific product IDs. These are products where I have determined I want to add credits to their account upon purchase.
  • For each product, I take the value of the custom field that is already there. I then add the new credits to the existing balance. I then put it back into the input parameters that will then...
  • Use the API to save those new credit balances back to their account.

Now, the actual code that I use is longer than above. I have more product IDs being scanned for.

Also, it is important to understand how to reference MemberMouse custom fields in code like this. Each custom field has an ID number. If that ID number is 14, for instance, then you will reference it using "cf_14".

The End Result - And Taking It Further

Yes, this is nerdy. But, it does the job.

The end result is that when a member purchases any of those product IDs, the system will automatically increment their credit balances accordingly. If they buy a strategy session call, it will add one to their credit balance.

Then, when somebody goes to actually SCHEDULE a call with me, I use Calendly for that. My Calendly is embedded into the site. I use a custom page template for that. In the code of that template, I check their credit balance. As long as they have 1 or more credits on their balance for a strategy call, they can access the calendar. If their balance is zero, it shows them a call to action to purchase some call credits.

Make sense?

Cool. 🙂 

The geekiness can get even more developed if you wish. For instance...

For technical service requests, I use Gravity Forms for them to submit that request. Just like strategy calls, they must have 1 or more tech service credits on their account to access that form and being able to submit a request for done-for-you service.

When they purchase tech service credits, it adds credits in just the same way. But, when they submit a service request, I make use of the Gravity Forms hooks to DEDUCT a credit from their balance.

Gravity Forms has a hook called gform_after_submission_XX, where "XX" is the ID number of the form itself.

So, you just create another PHP function and hook it to that. Use the MemberMouse API to fetch the current credit balance. Reduce it by 1. Then, use the API again to re-save their new credit balance back to their account. And this takes place all automatically when they submit the Gravity Form.

Cool, huh? 🙂

How To Implement This

This solution is very MemberMouse specific. But, it could likely be done in other ways, using different plugins and different hooks.

In fact, since I am (as of this writing) in the process of migrating away from MemberMouse, I have devised another way which uses custom fields created by Advanced Custom Fields and hooked directly to the user profile. More on that later. 🙂 

Truth is, some site operations are difficult to do using "out of the box" plugins alone. Sometimes, you still need a bit of custom code to pull off an operation specific to your business. Most solid plugins have tons of hooks and even APIs that allow you to extend and customize functionality. MemberMouse is one of those... and we used it in this instance.

If you're adept enough with PHP code and working with APIs, I hope this has given you some head start.

If not, perhaps we can help you implement it. Click here to add a technical service credit to your own account. 🙂 Then, we'll use that credit to see about having us duplicate this setup for your own membership site.


TOPICS


Related Articles You Might Like:

Why And How I Switched My Optins From Thrive Leads To ConvertBox

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>
14 Shares
Share
Tweet
Share