Hello Bubblers,
I am trying to organize my e-shop and integrate the discount on some products if users use their points:
Things:
POINTS
Number (number)
Related Product (Product)
PRODUCT
Name (text)
Price (number)
Price with discount (number)
Discounted points (number)
LINE ITEM
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.
- If user has enough points for this specific product
- 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
Hello,
You can use the state, but I think a feeling tells you that there is a better way? 
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.