Quote Originally Posted by SeanLoberg View Post
v1.5 version: http://www.zen-cart.com/downloads.php?do=file&id=704

Feature Question: the rewards program allows the automatic expiration of PENDING points by setting a future expiration in days:

admin > config > rewards points config > Delete Old Reward Transactions Period = 30 days (for example below)

For example, a customer buys product, receives 1000 points that are PENDING until the order has shipped, triggering the 1000 points to move from PENDING to EARNED. If the order does not ship in 30 days, the PENDING points expire. No problem, tested and works fine.

What I want to do is expire EARNED points in 30 days. For example, a customer buys product, receives 1000 points that are PENDING. The the order is shipped, triggering the 1000 points to move from PENDING to EARNED. If the customer does not use/redeem the EARNED 1000 points in 30 days, the EARNED points automatically expire. A "Use 'em or Loose'em" scenario.

Does this feature exist in the Mod? If not, any pointers on how to create this function ... Help greatly appreciated!
I don't think you will get an answer to your question because I asked the same question perhaps a month or two ago, I think the module is not setup for that so I got one of my family members write me a code which I run daily, it's not the perfect way but itworks, you could set it up as a cron job if you like to run it daily, here is the code below:

<?php

try {
$dbh = new PDO("mysql:host=localhost;dbname=DATABASE_NAME", 'DATABASE_NAME_Points', '1qwer13');

$Totalquery = "Update reward_customer_points
SET reward_points = 0.00
Where customers_id not in (select customers_id from reward_status_track)";


$Totalstmt = $dbh->prepare($Totalquery);
$Totalstmt ->execute();

echo 'Total Task Completed';

}
catch(PDOException $e)
{
echo $e->getMessage();
}

?>

Basically when you set up your reward points module pending points to expire in 30 days, the reward_status_track table keeps only 30 days of records so what the code does if it's not in the track table then it sets the points to Zero.

You have to run this daily though, if not then the deleted records will be lost and won't be able to zero the reward points that are older than 30 days.

I am sure some people here could make it much better and full proof and run it as a cron job.

I am not an expert in code writing but was able to figure things out to solve my problem.

Hope this helps,