# Points formulas

This documentation is for the WooRewards plugin

Points formulas is a way to push your loyalty program even further. In fact, it provides you with new ways to express your creativity and reward your customers.

Summary

## What is it ?

In WooRewards, there are multiple places where you can set points values. For example, performing an action grants users points. In addition, redeeming a reward costs points.

With points formulas, instead of setting a fix points value, you have the possibility to set a formula. As a result, the points value will vary, depending on the situation.

The possibilities are endless. However, it will require some learning to get the best of it. Let’s begin now with the basics.

## Operators

WooRewards supports basic operators. Therefore, you’ll find here the following possibilities

This is pretty standard. Let’s complete it with some basic examples of formulas you can use.

With these few examples, you can see that it’s fairly easy to set formulas. And useless too at this point. This is why, in the following section, we’ll see how to add some useful values.

## Functions

In addition to operators, there are a couple of functions you can use in your formulas. Here are the available functions :

## Variable values

Now, let’s get to the good stuff. To set formulas that will help you set up the perfect loyalty program, you need some variables. Here are the possibilities :

This immediately looks a lot more complicated. But don’t worry, it’ll become crystal clear (almost) with a few examples.

Finally, here are some other variable values that **only work for methods to earn points tied to an order**. For example, you can use it for the points methods “Spend Money”, “Place an order”, “Buy specific products” …

## Formulas examples

Now that we have a list of all possible values, let’s try them with some examples. Of course, these are only some of the possible uses of points formulas. The only limit is your creativity. Don’t hesitate to share your formulas with us !

### Earn more points in higher levels

In this example, we’ll consider that you have a leveling system. The first level is at 1 point, the second level at **200** points and the third level at **500** points. At level 1, customers earn **1 point for each $1** spent. At level 2 they will earn **2 points for each $1** spent and, finally, at level 3, they will earn **3 points for each $1** spent.

Your leveling points and rewards system uses the **leveling** points reserve. Here is the formula to use :

`=1 + ({points:leveling} > 199) + ({points:leveling} > 499)`

### Points equal to the customer’s age

If you want to offer a birthday gift to your customers that depend on their age, this formula is for you.

`=round@ (({time} - {user_timestamp:billing_birth_date}) / (60*60*24*365))`

### More points depending on the user role

If you have a leveling system that gives specific user roles to your customers, you can also change how many points they earn depending on their role. In this example, we’ll say that **Bronze members earn 10 points, Silver members earn 20 points and Gold members earn 50 points**. Here’s the points formula :

`=({role:bronze} * 10) + ({role:silver} * 20) + ({role:gold} * 30)`

### Give more points on a user’s birthday

If you want to give more points to users on their birthday, use this formula. Here, customers will earn 1 point when it’s not their birthday and 2 points when it’s their birthday :

`= 1 + (equal@ (date@ {time}, 'd'), (date@ {user_timestamp:billing_birth_date}, 'd')) * (equal@ (date@ {time}, 'm'), (date@ {user_timestamp:billing_birth_date}, 'm'))`

### Earn more points depending on the order amount

In this example, we’ll see how to give more points depending on the order total amount. For orders under $100, customers will earn 1 point. For orders between $100 and $200, customers will earn 3 points. Finally, for orders above $200, customers will earn 10 points :

`=1 + (({order:total} > 99) * 2) + (({order:total} > 199) * 7)`

## Some more tips

Points formulas also work on the “Generate Points” reward. You can use that to expand even further your loyalty program.

Don’t hesitate to experiment or ask us for help if you’re stuck with a formula.