Forums / All Other Contributions/Addons / Reward Points Module for ZC v13x

Reward Points Module for ZC v13x

Locked

Views: 472,173

Results 2,381 to 2,400 of 2,476
This thread is locked. New replies are disabled.
14 Feb 2014, 4:16 AM
#2381
countrycharm avatar

countrycharm

Totally Zenned

Join Date:
Jul 2007
Posts:
2,179
Plugin Contributions:
2

Reward Points Module for ZC v13x

bryan22:

Hello, just wanted to report what i think is a bug.

The Issue:
When a sale is active the reward points show properly on product details pages, but incorrectly at checkout and are added with pre sale values.
The Solution: In catalog/includes/functions/extra_functions/reward_points_functions.php -> function GetProductRewardPoints
when checking to see if a sale price is active it also stipulates the condition && !$attributes.

I believe this to be error - the result is that products with attributes do not get rewards points for special pricing. The fix for me is just to remove that condition. now the condition is this...

$special_price=zen_get_products_special_price($products_id);

        if(REWARD_POINTS_SPECIAL_ADJUST=='1' && $special_price )
         $reward_price=$special_price;
> 
> Hopefully this helps someone. I've also made a small hack to make the maximum points per purchase an ultimate maximum if anyone is interested in that, ie customers cannot receive more than 'n' number of points before spending more.

You are the first person to ever report a bug in Sales/Specials. I have checked my test site and I don't have the problem you are experiencing  neither has anybody else. 

Go back and make sure all the reward points files uploaded correctly. It is something in your installation not in the module. 

Also the hack you are offering makes no sense. Reward points was created to reward customers when they purchase products from your site. Why would you penalize the customer from earning more points just because they don't spend them when you want them to.  There is a feature in admin/modules/order total/Reward Points you can set to Automatic. It will select all Reward Points earned by the customer and enter them at checkout. So the hack you have come up with is of no use.

Is your site Upgraded to the current version 1.5.4 Yet?
zencart-upgrades-website-installation

14 Feb 2014, 5:55 AM
#2382
countrycharm avatar

countrycharm

Totally Zenned

Join Date:
Jul 2007
Posts:
2,179
Plugin Contributions:
2

Re: Reward Points Module for ZC v13x

ripvoid:

do you know why it does not work with 1.5.1 in the admin editing orders show 0.00 points but in invoices it show them can any one help-??

The reason the reward points in admin/customers/orders/edit order will not show is because, the reward points is different with the total of,
100 points = $1 so the reward points can not save the points value in database so you see it's 0.00

Check the orders_totals table and you will understand whats going on.

I know it is hard to understand but that's the best I can explain it.

Is your site Upgraded to the current version 1.5.4 Yet?
zencart-upgrades-website-installation

14 Feb 2014, 9:23 PM
#2383
bryan22 avatar

bryan22

New Zenner

Join Date:
Jul 2013
Location:
California
Posts:
4
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

countrycharm:

You are the first person to ever report a bug in Sales/Specials. I have checked my test site and I don't have the problem you are experiencing neither has anybody else.

Go back and make sure all the reward points files uploaded correctly. It is something in your installation not in the module.

Also the hack you are offering makes no sense. Reward points was created to reward customers when they purchase products from your site. Why would you penalize the customer from earning more points just because they don't spend them when you want them to. There is a feature in admin/modules/order total/Reward Points you can set to Automatic. It will select all Reward Points earned by the customer and enter them at checkout. So the hack you have come up with is of no use.

If it's not a bug, why does it check if !$attributes before setting the price to the special price? Maybe I missed the reasoning, but for me it was a bug and can easily be recreated. In any case it's here now so if someone else has the same problem they know where to look.

Anyways, thank you for a wonderful zen cart addition it works very well and does exactly what I wanted it to do with very minor modifications.

17 Feb 2014, 3:42 PM
#2384
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

Is it possible to make the sunrise period start after the order is marked "shipped" instead of having it start immediately after the order is placed?

17 Feb 2014, 4:47 PM
#2385
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

Coins2012:

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,

I need points to expire 90 days after they are earned.

This code is a good start, but I can see a problem...

Say we want rewards to expire at 90 days.
Day 1: Customer places order. Earns 100 points.
Day 30: Customer places another order. Earns 100 points.
Day 90: Only 100 points should be removed, not all of their points, which is what this code would do.

Has anyone determined how to properly remove earned points after a certain time period?

17 Feb 2014, 5:41 PM
#2386
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

abcisme:

I need points to expire 90 days after they are earned.

This code is a good start, but I can see a problem...

Say we want rewards to expire at 90 days.
Day 1: Customer places order. Earns 100 points.
Day 30: Customer places another order. Earns 100 points.
Day 90: Only 100 points should be removed, not all of their points, which is what this code would do.

Has anyone determined how to properly remove earned points after a certain time period?

Ok, I am not a programmer, so I am taking a stab in the dark at this.. but looking at the housekeeping function, if I create a subset for housekeeping which specifies earned points instead of pending points.. then switched the housekeeping function to reflect rewards_points instead of pending_points, it should work to remove any earned points instead of pending points. Right?

So pending points will switch to earned after the sunrise period, then be removed after the housekeeping period... Does this look correct?

function CleanupRewardPointHistory()
{
    global $db,$messageStack;
    
    $subset="IFNULL((SELECT SUM(rp.reward_points) FROM ".TABLE_REWARD_STATUS_TRACK." rp WHERE cp.customers_id=rp.customers_id AND rp.status='".STATUS_PENDING."' AND rp.date<NOW()-INTERVAL %s DAY),0)";
$subset2="IFNULL((SELECT SUM(rp.reward_points) FROM ".TABLE_REWARD_STATUS_TRACK." rp WHERE cp.customers_id=rp.customers_id AND rp.status='".STATUS_PROCESSED."' AND rp.date<NOW()-INTERVAL %s DAY),0)";
    $sunrise_subset=sprintf($subset,REWARD_POINTS_SUNRISE_PERIOD);
    $housekeeping_subset=sprintf($subset2,REWARD_POINTS_HOUSEKEEPING);
    
    if(REWARD_POINTS_SUNRISE_PERIOD>0)
     if($db->Execute("UPDATE ".TABLE_REWARD_CUSTOMER_POINTS." cp, ".TABLE_REWARD_STATUS_TRACK." rp SET cp.reward_points=cp.reward_points+".$sunrise_subset.",cp.pending_points=cp.pending_points-".$sunrise_subset." WHERE cp.customers_id=rp.customers_id;"))
      $db->Execute("UPDATE ".TABLE_REWARD_STATUS_TRACK." SET status=".STATUS_PROCESSED." WHERE status=".STATUS_PENDING." AND date<NOW()-INTERVAL ".REWARD_POINTS_SUNRISE_PERIOD." DAY;");
     
    if(REWARD_POINTS_HOUSEKEEPING>0)
     if($db->Execute("UPDATE ".TABLE_REWARD_CUSTOMER_POINTS." cp, ".TABLE_REWARD_STATUS_TRACK." rp SET cp.reward_points=cp.reward_points-".$housekeeping_subset." WHERE cp.customers_id=rp.customers_id;"))

      $db->Execute("DELETE FROM ".TABLE_REWARD_STATUS_TRACK." WHERE date<NOW()-INTERVAL ".(int)REWARD_POINTS_HOUSEKEEPING." DAY;");
}
21 Feb 2014, 9:49 AM
#2387
speedyrider avatar

speedyrider

New Zenner

Join Date:
Jan 2014
Posts:
32
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

Hi,

in my site, when i change attributes the points dont change, please take a look: 66.147.242.164/~kiteaddi

21 Feb 2014, 7:50 PM
#2388
dmagic avatar

dmagic

Totally Zenned

Join Date:
Oct 2008
Posts:
594
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

can share products ( facebook, twiiter ) and get points ?

22 Feb 2014, 1:24 AM
#2389
countrycharm avatar

countrycharm

Totally Zenned

Join Date:
Jul 2007
Posts:
2,179
Plugin Contributions:
2

Re: Reward Points Module for ZC v13x

dmagic:

can share products ( facebook, twiiter ) and get points ?

Could you be more clear in what you are asking. If your asking if someone shares your products on facebook, twiiter and receive reward points for doing that, the answer is no. You will have to hire someone to custom coded reward points to do that.

Is your site Upgraded to the current version 1.5.4 Yet?
zencart-upgrades-website-installation

26 Feb 2014, 6:31 PM
#2390
speedyrider avatar

speedyrider

New Zenner

Join Date:
Jan 2014
Posts:
32
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

Hi,

I have a problem where if i enter in a product´s page it shows the current amount of points i should get for that product.

However when i actually add it to the cart it never adds the correct points. It doesnt matter if i set the ratio to 0.0, 0.5, to 2.0, it always adds the global ratio points (which is now set to 1).

My zen_reward_master table for a given category looks like this: point ratio (for category) = 0.5 (For example). Bonus points = null. redeem points = null. redeem ratio = null

Any ideas?

5 Mar 2014, 10:56 AM
#2391
defkon1 avatar

defkon1

New Zenner

Join Date:
Sep 2012
Posts:
3
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

I have the following problem: in the product page the points are calculated on base price (wrong) and when I add it to the cart they are calculated on the subtotal (base price+taxes - right).

how to fix the points amount shown in product page?

thanks in advance

5 Mar 2014, 11:32 AM
#2392
defkon1 avatar

defkon1

New Zenner

Join Date:
Sep 2012
Posts:
3
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

Defkon1:

I have the following problem: in the product page the points are calculated on base price (wrong) and when I add it to the cart they are calculated on the subtotal (base price+taxes - right).

how to fix the points amount shown in product page?

thanks in advance

Actually I temporarily fixed adding to reward_points_function.php:90 the following code:

//DFK - add taxes to reward_price
$taxrate = zen_get_tax_rate($result->fields['products_tax_class_id']);
$reward_price+= $reward_price*$taxrate/100;

and adding "p.products_tax_class_id" field in the select query...

there's any cleaner way to fix this?

7 Mar 2014, 5:27 AM
#2393
mcpisik avatar

mcpisik

Zen Follower

Join Date:
Jan 2007
Location:
Mount Maunganui, New Zealand
Posts:
417
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

In my log files I have the following myDEBUG files going on...
PHP Warning: Invalid argument supplied for foreach() in ..../includes/functions/extra_functions/reward_points_functions.php on line 314

I found a couple of others mentioning the problem far back long ago in this forum, but couldn't spot any solution if one was found.
Can anyone suggest how to trouble shoot or what the error means?

Line 314 reads: foreach($module_list as $module)
Line 315 if($module['action']=="Subtract")

14 Mar 2014, 4:57 AM
#2394
ifss avatar

ifss

New Zenner

Join Date:
Oct 2013
Location:
Australia
Posts:
13
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

Hi there,
Looking for a "best practice" piece of advice please :)

I want to update a bulk load of reward points, something like: Customers who purchased X get bonus points.
I was thinking about doing this in SQL or something similar:

update reward_customer_points 
set pending_points = 10000 
where products_id = 3

Then letting the system allocate them overnight.

Unless I can ADD them (not rewrite the value) to existing earned (reward_points) (so 300, 500, 725 becomes 10300, 10500, 10725 as I'm adding 10000).

What is the best way of doing this as I don't want to manually allocate 300 orders :) Thank you.

23 Mar 2014, 3:21 AM
#2395
ifss avatar

ifss

New Zenner

Join Date:
Oct 2013
Location:
Australia
Posts:
13
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

Just a gentle bump.
I'm looking at either "add to pending" then wait (if SQL modified points added to pending will update overnight), or a way to combine existing points to a new value.

Which is the best way of doing this (as per my previous post, and this one).

Cheers.

28 Mar 2014, 8:45 PM
#2396
southshorepizza avatar

southshorepizza

Zen Follower

Join Date:
Sep 2012
Posts:
253
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

Originally Posted by southshorepizza
Okay so I have done all of these things. I also have gone back in and found post 441-451 in this thread about my last attempt at the upgrade. I have the same results!

Log says
[28-Mar-2014 14:24:44] PHP Fatal error: Call to undefined function getrewardpoints() in /home4/w57dsjmm/public_html/order/includes/modules/order_total/ot_reward_points_display.php on line 40

however line 40 of said file is $reward_points=GetRewardPoints($order->products);

I feel as if this is ground hog day all over again!
And do you have a GetRewardPoints function in \admin\includes\functions\extra_functions\reward_points_functions.php. (case sensitivity counts..) You would copy over the one from the store side function file.. Saying you did what was suggested and still got an error doesn't provide enough info to determine why.. POST the changes you made to the admin functions file.. The error says you DON'T have the function in admin functions file.. might be best if you not only post the part you added but a couple of lines above and below it to make sure you didn't add e character that isn't supposed to be there.. (on the Rewards Points support thread of course )

Diva Vocals or anyone else,

I don't have anything here:
\admin\includes\functions\extra_functions\reward_points_functions.php.

I do have the file indicated in the log at:
/order/includes/modules/order_total/ot_reward_points_display.php

As indicated in the log the error is:
Call to undefined function getrewardpoints()

As Ilhungil indicated that it should be a call to function GetRewardPoints() but for some reason the log shows it all in lower case.

My file at /order/includes/modules/order_total/ot_reward_points_display.php I will put line 40 in red text but the file looks like this:

class ot_reward_points_display 
{
    var $title, $output;

    function ot_reward_points_display() 
	{
		$this->code = 'ot_reward_points_display';
		$this->title = MODULE_ORDER_TOTAL_REWARD_POINTS_DISPLAY_TITLE;
		$this->description = MODULE_ORDER_TOTAL_REWARD_POINTS_DISPLAY_DESCRIPTION;
		$this->sort_order = MODULE_ORDER_TOTAL_REWARD_POINTS_DISPLAY_SORT_ORDER;
		
		$this->output = array();
    }

    function process() 
	{
		global $order;

		$reward_points=GetRewardPoints($order->products);
		
		$GlobalRewardPointRatio=GetGlobalRewardPointRatio();
		$AdjustValue=GetRewardPointAdvancedCalculateValue();
		$reward_points+=$AdjustValue*$GlobalRewardPointRatio;
		
		if(isset($_SESSION['redeem_value']))
		{
			/*
			$redeem_ratio=GetRedeemRatio($_SESSION['customer_id']);
			$reward_points=$reward_points/$redeem_ratio;
			$reward_points=$reward_points-$_SESSION['redeem_value'];
			$reward_points=$reward_points*$redeem_ratio;
			*/
			$reward_points=$reward_points-($GlobalRewardPointRatio*$_SESSION['redeem_value']);
		}

		if($reward_points<0)
		 $reward_points=0;
		
		$reward_points=zen_round($reward_points,0);
		$_SESSION['REWARD_POINTS_EARNED']=$reward_points;
		 
		$this->output[] = array('title' => $this->title . ':',
                              'text' => $reward_points,
                              'value' => 0);
    }

    function check() 
	{
		global $db;
		if (!isset($this->_check)) 
		{
			$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_REWARD_POINTS_DISPLAY_STATUS'");
			$this->_check = $check_query->RecordCount();
		}

		return $this->_check;
    }

    function keys() 
	{
		return array('MODULE_ORDER_TOTAL_REWARD_POINTS_DISPLAY_STATUS', 'MODULE_ORDER_TOTAL_REWARD_POINTS_DISPLAY_SORT_ORDER');
    }

    function install() 
	{
		global $db;
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_REWARD_POINTS_DISPLAY_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\',\'false\'), ', now())");
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_REWARD_POINTS_DISPLAY_SORT_ORDER', '1000', 'Sort order of display.', '6', '2', now())");
    }

    function remove() 
	{
		global $db;
		$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }
}
?>

If I am supposed to have this file in the Admin root as well that could be my problem. But I don't think I'm missing a file there or the log would have given me that address wouldn't it?

28 Mar 2014, 9:07 PM
#2397
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Reward Points Module for ZC v13x

southshorepizza:

... I don't have anything here:
\admin\includes\functions\extra_functions\reward_points_functions.php. ...
If you are indeed using Reward Point Full Suite (and the file you mentioned does not exist), it sounds like the module is not installed correctly. Adding the file "/admin/includes/functions/extra_functions/reward_points_functions.php" is part of the installation of Reward Point Full Suite. If files are missing, best to re-install (after making a backup of course).

Once everything is installed correctly there will be a file in that location and one can follow the instructions in this post.


Note: When people refer to file paths starting with "admin" they are referring to the physical name of the folder where the administrative files for Zen Cart are located. In Zen Cart 1.5+ this will what one renamed the admin folder to during the installation. For example, if you access the Zen Cart administrative interface using "https://mysite.com/my_secret_admin_xYe5Ade/"... Then the above mentioned file should be located at "/my_secret_admin_xYe5Ade/includes/functions/extra_functions/reward_points_functions.php".

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

28 Mar 2014, 9:15 PM
#2398
southshorepizza avatar

southshorepizza

Zen Follower

Join Date:
Sep 2012
Posts:
253
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

Thank you. It is a little after 5pm here on a Friday. I guess tonight after dinner rush(I'm in a pizza restaurant) I'll reinstall the rewards module. I don't know how I have a partial install. I swear I have uninstalled and reinstalled this thing several times. But I'll try it again. :frusty:

I'll post back my results. I'm renaming the admin folder and then using filezilla to upload these files. So I would assume they are going into the right directories!

Thanks again for your help. I hope I can get this sorted out. E.O 4.1 looks awesome! Rewards Points is a great add on for my customers as well. They love it!

28 Mar 2014, 11:42 PM
#2399
countrycharm avatar

countrycharm

Totally Zenned

Join Date:
Jul 2007
Posts:
2,179
Plugin Contributions:
2

Re: Reward Points Module for ZC v13x

southshorepizza:

Thank you. It is a little after 5pm here on a Friday. I guess tonight after dinner rush(I'm in a pizza restaurant) I'll reinstall the rewards module. I don't know how I have a partial install. I swear I have uninstalled and reinstalled this thing several times. But I'll try it again. :frusty:

I'll post back my results. I'm renaming the admin folder and then using filezilla to upload these files. So I would assume they are going into the right directories!

Thanks again for your help. I hope I can get this sorted out. E.O 4.1 looks awesome! Rewards Points is a great add on for my customers as well. They love it!

It's as lhungil said. You have not installed Reward Points correctly. You simply have not named the admin folder correctly.

Is your site Upgraded to the current version 1.5.4 Yet?
zencart-upgrades-website-installation

29 Mar 2014, 4:05 AM
#2400
southshorepizza avatar

southshorepizza

Zen Follower

Join Date:
Sep 2012
Posts:
253
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

I looked at the upgrade folder for v1.5.0 it doesn't have a functions or extra functions folder. That is where part of my error is.

Okay so I renamed the admin folder. Filezilla uploaded the new installation files. Tried to load the new install SQL and received the white page error message. The error log showed:
28-Mar-2014 23:47:33] PHP Fatal error: 1062:Duplicate entry '0-0' for key 'unique_id' :: INSERT INTO zen_reward_master (rewards_products_id ,scope ,scope_id ,point_ratio ,bonus_points, redeem_ratio, redeem_points) VALUES (NULL , '0', '0', '1.0000', NULL, 0.01, NULL); in /home4/w57dsjmm/public_html/order/includes/classes/db/mysql/query_factory.php on line 120

So I went back to the instal sql patch page and uploaded the upgrade sql file and ran it. 9 statements processed so every thing looked good.

Now when giving out points I get the following error log:
[28-Mar-2014 23:48:11] PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND status=0 ORDER BY date DESC LIMIT 12' at line 1 :: SELECT rewards_id, orders_id, date, reward_points, status FROM zen_reward_status_track WHERE customers_id= AND status=0 ORDER BY date DESC LIMIT 12; in /home4/w57dsjmm/public_html/order/includes/classes/db/mysql/query_factory.php on line 120

I had the problem before and never received an answer. Diva Vocals said she could see the problem by the log but not where or how to fix it which left me with no answer. Shortly thereafter I went ahead and uploaded my backup files to my earlier version. I'd really like to get this fixed!
The error log was generated when I transferred points from pending to earned.

Please help me

Thank you,
David