Create a discount on a product's price if user has available pointspoints

Hello Bubblers,

I am trying to organize my e-shop and integrate the discount on some products if users use their points:

Number (number)
Related Product (Product)

Name (text)
Price (number)
Price with discount (number)
Discounted points (number)

Quantity (number)
Applied Discount (Y/N)
Applied Discount (number)
Subtotal (number)
Related Product (Product)
Related Order (Order)

Basically, when a user is adding an item to his order, we have different conditions to apply a discount.

  1. If user has enough points for this specific product
  2. If cumulated discounted points are not over total number of points

This second point is tricky for me, I tried it with custom state. But, should I used a custom state? and how ?

Or any other tip would be great , thank you

You can use the state, but I think a feeling tells you that there is a better way? :joy:

You felt right. The states are very good, but they have one problem, we have to give them value or update them ourselves.

A better way to store data that is changing is to use group data.

You can have a group that is a number and set the sum of order points in it.
Now you can make another group with data yes/no and its only duty is to make this comparison.

Then, with a simple condition, as soon as the order’s score is higher than the user’s, you can give a warning or anything else.

Hi, and thank you for the answer,

I’m trying to do that :
I created 2 groups as you said, with one being “number” and the other being “Y/N”

I am bit lost about calculating the sum of accumulated discounted points , because the group is only showing one thing.

Could you be more specific please?
or Could you recommand a video on YT or other platform do see how it works ?

1 Like

Hi, treat that number as a variable. You have the items of the order, so start by searching them and then the points of each one, and finally use the summation.