WordPoints / wordpoints

Points plugin for WordPress
GNU General Public License v2.0
20 stars 15 forks source link

Support dynamically calculated points values in points hook reactor #469

Closed JDGrimes closed 7 years ago

JDGrimes commented 8 years ago

Previously: https://github.com/WordPoints/hooks-api/issues/25

At some point we need to introduce an API that will let the number of points awarded be dynamic. For example, it could be based on a post's word-count or an order's dollar-value.

Related: #248

JDGrimes commented 7 years ago

Probably there should also be minimum and maximum settings, so that a user can have the number of points be the number of dollars spent on the purchase, but no more than 50 and no less than 5. So if they spent just one dollar, they'd still get five points, and if they spent 100 dollars, they'd still get just 50.

JDGrimes commented 7 years ago

The real issue here is going to be deciding how best to handle rounding in cases when we are dealing with a decimal value and not an integer. Even when we are dealing with an integer, the user may want to have a ratio of 10:1 or 2:1, etc. So there again will need to use rounding. I guess we could let the user select how to round, up/down/ceiling/floor/etc. Other options could be added, too, I guess.

JDGrimes commented 7 years ago

The min and max thing could actually be achieved using multiple reactions. However, multiple reactions may not always work as the user wants them to, since they have separate limits, rate limits, etc.

JDGrimes commented 7 years ago

I just keep wondering to myself whether this is really core material. It kind of seems like something that could go into a generic module, not a basic feature that ought to be in core. We do, at the very least, need to make it possible to handle this gracefully though.

JDGrimes commented 7 years ago

I'd say the best thing for us to do here is to work on it as if it was a module. That will force us to make our APIs extensible. Then if we decide to fold it into core one day, we've still forced ourselves to make those improvements.

JDGrimes commented 7 years ago

Well, we've created the module, and I think that this will stay as a module, for now at least. We've made the changes in core necessary to make it happen. So let's close this.