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

Reward Points Module for ZC v13x

Locked

Views: 472,223

Results 2,401 to 2,420 of 2,476
This thread is locked. New replies are disabled.
29 Mar 2014, 4:32 AM
#2401
southshorepizza avatar

southshorepizza

Zen Follower

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

Reward Points Module for ZC v13x

I am wondering if this area of admin/customer_reward_points.php is what is causing me an issue when I transfer all pending points to earned points. I have no idea how to read this or modify it if it is the area. But the wording does look like it matches the error log and I am transferring all to earned.

 case 'update':
		if(isset($_GET['id']))
		{
			$id=$_GET['id'];
			if(isset($_REQUEST['customers_reward_group']))
			 $db->Execute("UPDATE ".TABLE_CUSTOMERS." SET customers_group_pricing=".$_REQUEST['customers_reward_group']." WHERE customers_id=".$id.";");
			 
			$pending_delta=0;
			$earned_delta=0;
			if(($current_reward_points=GetCustomerRewardPointsRecord($id))!=null && isset($_REQUEST['total_points_action']))
			 switch($_REQUEST['total_points_action'])
			 {
				case 'TransferAllToEarned':
					$earned_delta+=$current_reward_points->fields['pending_points'];
					$pending_delta-=$current_reward_points->fields['pending_points'];
					$db->Execute("UPDATE IGNORE ".TABLE_REWARD_STATUS_TRACK." SET status=".STATUS_PROCESSED." WHERE customers_id=".$id." AND status=".STATUS_PENDING.";");
					break;
29 Mar 2014, 5:16 AM
#2402
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Reward Points Module for ZC v13x

southshorepizza:

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!At the risk of pissing you off.. No you haven't "done all of these things" or if you think you did, it's clear from the information you provided that you've not done them correctly..

I say this based on the error message you posted you are getting.. if you followed the steps in this post, you would not be getting the error you are getting and you would have a "\YOUR_ADMIN\includes\functions\extra_functions\reward_points_functions.php" file in your store.. By your own admission this file does NOT exist in your store's admin area, so I'm not sure how you followed the instructions in this post if you don't have the file that this post says you need to modify.. You appear to have an INCOMPLETE Rewards Points install.. Which is WHY YOU ARE GETTING THE ERROR..

southshorepizza:

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);You are MISINTERPRETING what this error message ACTUALLY means.. so let me interpret here..

Line 40 in the "includes/modules/order_total/ot_reward_points_display.php" file makes a call to a function that DOES NOT EXIST.. Because it does not exist, the error log tells you where this call was made (line 40 of the ot_reward_points_display.php file), and the name of the function being called ( getrewardpoints() ).

The error says that a function called "getrewardpoints()" has not been defined in your functions file.. This means either
A. The functions file does not exist (hence why the error log says it's MISSING)
B. The functions file exists and the function is not DEFINED in it (hence why the error log says it's MISSING)

This post you say you followed provides instructions for adding this function to the ADMIN function file so Edit Orders will NOT throw this error..

southshorepizza:

Diva Vocals or anyone else,

I don't have anything here:
\admin\includes\functions\extra_functions\reward_points_functions.php.Then you do not have Rewards Points fully installed. this file is part of the install package.. If you are MISSING this file then you have an INCOMPLETE install.. UNDO everything you say you've done.. Copy over the Rewards Points files again.. DO NOT run the SQL install file.. Let me say that again.. COPY OVER THE MISSING FILES, but DO NOT RE-RUN THE SQL!!

southshorepizza:

I do have the file indicated in the log at:
/order/includes/modules/order_total/ot_reward_points_display.phpAlready explained this above.. This file is making a call to a file/function that DOES NOT EXIST..

southshorepizza:

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()) . "')");
}

}
?>

> **southshorepizza:**
>
> If I am supposed to have this file in the Admin root as well that could be my problem.It IS your problem.. You are missing the functions file referenced in [this post](http://www.zen-cart.com/showthread.php?95021-Reward-Points-Module-Live-Release-now-available&p=1225423#post1225423)!!! If you do not have this file in your admin, you have an INCOMPLETE install of Rewards Points.. If you do not add the function file referenced in [this post](http://www.zen-cart.com/showthread.php?95021-Reward-Points-Module-Live-Release-now-available&p=1225423#post1225423), you will continue to get this error.. 

 > **southshorepizza:**
>
> But I don't think I'm missing a file there or the log would have given me that address wouldn't it?You are missing the file.. The error log tells us CLEARLY that:
A. The functions file does not exist (hence why the error log says it's MISSING)
B. The functions file exists and the function is not DEFINED in it (hence why the error log says it's MISSING)

Now I apologize for all the caps and such, but it is CLEAR to those of us trying to help you that you have an incomplete Rewards Points install and you have NOT followed the steps in [this post](http://www.zen-cart.com/showthread.php?95021-Reward-Points-Module-Live-Release-now-available&p=1225423#post1225423) to fix the Edit Orders/Reward Points issue.. Throwing everything at the wall to see what sticks instead of just simply TRYING what we are suggesting in [this post](http://www.zen-cart.com/showthread.php?95021-Reward-Points-Module-Live-Release-now-available&p=1225423#post1225423) isn't getting this resolved for you.. So here's the summary of what you DO need to do to fix this:

A. DOUBLE CHECK your Rewards Points installation. Based on the error logs you have posted and the information you have shared you are MISSING files in your install. If you really DO NOT have a "\YOUR_ADMIN\includes\functions\extra_functions\reward_points_functions.php" file then this is a BIG problem in the overall functionality of the Reward Points module
B. Once you compare your store to the Rewards Points fileset and make sure you have ALL the Rewards Points files in place then PLEASE follow the instructions in [this post](http://www.zen-cart.com/showthread.php?95021-Reward-Points-Module-Live-Release-now-available&p=1225423#post1225423).

After you do ONLY these things and NOTHING ELSE this should resolve the issue..:smile: If it doesn't then report the issue/error you get and we will all continue to try and help you resolve it..:smile:

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

29 Mar 2014, 2:50 PM
#2403
countrycharm avatar

countrycharm

Totally Zenned

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

Re: Reward Points Module for ZC v13x

southshorepizza:

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

If you have downloaded Reward Points Version: 2.1b, you will see that inside the new_installation folder is the admin folder. Inside the admin folder is includes/functions/extra_functions folder.

If you are using the Reward Points Full Suite Version: 2.1b admin/includes/functions/extra_functions folder will be there.

Now if your using Store Credits and Rewards Points Module that module don't use the admin/includes/functions folder.

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

29 Mar 2014, 4:52 PM
#2404
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

Ok lets start from scratch. Friday 11pm I downloaded from http://www.zen-cart.com/downloads.php?do=file&id=704
The folder called reward_point_full_suite_2.1b
I renamed the admin folders in the following directory
reward_point_full_suite_2.1b/reward_point_full_suite_2.1b/zen_1.5.0/new_installation

I then used filezilla to upload them to my site 3/28/14 at 11:45pm. And have already posted the rest of that adventure at 3/29/14 12:05am.

Now I just finished using cpanel to check every one of those files to make sure they made it to my site. Each one is there and was last modified 3/28/14 at 11:45pm. So I am good there.

So let me follow Diva Vocals post line by line.

  1. if you followed the steps in this post. Done now and verified.(I had done this but overwritten it with my ftp upload) ☹
  2. By my own admission this file does not exist. That was at 4:45 pm. My last post at 12:05 am explained that the upgrade folder for v1.5.0 doesn’t have that folder and that was an initial error.. I did not explain that at 5pm I had found the “missing folder” uploaded it and made the changes in step one before giving up. My mistake as you surely wouldn’t know this you just thought I didn’t do it still. But my 11:45 upload overwrote it. It’s fixed now.
  3. Same link. I just verified that the changes were there just to be sure. ☺ I searched for the whole addition as one big piece and have 1 match. So we are good there.
  4. I don't have anything here: \admin\includes\functions\extra_functions\reward_points_functions.php. Again going back before the complete reinstall that happened before giving up at 5 and then reuploading everything at 11:45

Here is a pic of cpanel showing the file in this post
Attachment 13927
Just to make sure I place the code from "this post" In the right spot I am including the code just before and formatting the beginning of the added code in red.

/*
function SetRewardPointDiscountTypeFunction($value,$key='')
{
    require('includes/javascript/reward_points.js');
    
    $content='<br />';
    
    $content.='<strong>'.TEXT_NEW_ACCOUNT_AWARD_PROMPT.'</strong> '.zen_draw_checkbox_field('allow_award','',$value!=0,0,'onchange="UpdateAward()"');
    $content.=zen_draw_input_field('award_points',($value==0?'':abs($value)),'onchange="UpdateAward()"').' '.zen_draw_pull_down_menu('award_id',array(array('id'=>'0','text'=>TEXT_NEW_ACCOUNT_PENDING_AWARD),array('id'=>'1','text'=>TEXT_NEW_ACCOUNT_EARNED_AWARD)),($value<0?'0':$value>0?'1':''),'onchange="UpdateAward()"').'<br />';
    $content.=zen_draw_hidden_field('configuration_value',$value);

    return $content;
}
function GetRewardPoints($products) 
{ 
    $reward_points=0; 
    if(REWARD_POINT_MODE=='0') 
    { 
        foreach($products as $product) 
         if(isset($product['qty'])) 
          $reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])*$product['qty']; 
         else 
          if(isset($product['quantity'])) 
           $reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])*$product['quantity']; 
          else 
           if(isset($product['quantityField'])) 
            $reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])*$product['quantityField']; 
          else 
           $reward_points="RP Error"; 
    } 
blah blah blah  here is the end of the file to make sure I didn't screw up the ending.
 //print_r($GLOBALS[$module]->output); 
        //$output_backup=$GLOBALS[$module]->output; 
        //$order_info_backup=$order->info; 
        //if(sizeof($GLOBALS[$module]->output)==0) 
         //$GLOBALS[$module]->process(); 
        for($loop=0;$loop<sizeof($GLOBALS[$module]->output);$loop++) 
         if(zen_not_null($GLOBALS[$module]->output[$loop]['value'])) 
          $value+=$GLOBALS[$module]->output[$loop]['value']; 
                   
        //$GLOBALS[$module]->output=$output_backup; 
        //$order->info=$order_info_backup; 
    } 
    return $value; 
}  
*/
?>
```

So with all of this done.  

If it has been done right. 
 
I go into reward points admin.  Transfer 35 points from pending to earned.  

I generate this log:
[29-Mar-2014 12:33:00] 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

Now I know I'm not the most computer literate person.  But I downloaded a fresh version yesterday.  So if my copy was bad I had the newest version available.  I have confirmed files located in the correct spot.  Made and confirmed the change to the function file.  Yet I'm still getting this error.  If someone is willing to look at my actual files and confirm I'm not crazy please let me know.  I know you all are frustrated and I am as well.  

Thank you for all your help Diva Vocals.  I didn't mind the caps or bold text or anything else you throw my way if it fixes the problem!  I'm a big boy and can take a few capitalized words. :)
29 Mar 2014, 5:03 PM
#2405
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Reward Points Module for ZC v13x

southshorepizza:

Ok lets start from scratch. Friday 11pm I downloaded from http://www.zen-cart.com/downloads.php?do=file&id=704
The folder called reward_point_full_suite_2.1b
I renamed the admin folders in the following directory
reward_point_full_suite_2.1b/reward_point_full_suite_2.1b/zen_1.5.0/new_installation

I then used filezilla to upload them to my site 3/28/14 at 11:45pm. And have already posted the rest of that adventure at 3/29/14 12:05am.

Now I just finished using cpanel to check every one of those files to make sure they made it to my site. Each one is there and was last modified 3/28/14 at 11:45pm. So I am good there.

So let me follow Diva Vocals post line by line.

  1. if you followed the steps in this post. Done now and verified.(I had done this but overwritten it with my ftp upload) ☹
  2. By my own admission this file does not exist. That was at 4:45 pm. My last post at 12:05 am explained that the upgrade folder for v1.5.0 doesn’t have that folder and that was an initial error.. I did not explain that at 5pm I had found the “missing folder” uploaded it and made the changes in step one before giving up. My mistake as you surely wouldn’t know this you just thought I didn’t do it still. But my 11:45 upload overwrote it. It’s fixed now.
  3. Same link. I just verified that the changes were there just to be sure. ☺ I searched for the whole addition as one big piece and have 1 match. So we are good there.
  4. I don't have anything here: \admin\includes\functions\extra_functions\reward_points_functions.php. Again going back before the complete reinstall that happened before giving up at 5 and then reuploading everything at 11:45

Here is a pic of cpanel showing the file in this post
Attachment 13927
Just to make sure I place the code from "this post" In the right spot I am including the code just before and formatting the beginning of the added code in red.

/*
function SetRewardPointDiscountTypeFunction($value,$key='')
{
require('includes/javascript/reward_points.js');

$content='<br />';

$content.='<strong>'.TEXT_NEW_ACCOUNT_AWARD_PROMPT.'</strong> '.zen_draw_checkbox_field('allow_award','',$value!=0,0,'onchange="UpdateAward()"');
$content.=zen_draw_input_field('award_points',($value==0?'':abs($value)),'onchange="UpdateAward()"').' '.zen_draw_pull_down_menu('award_id',array(array('id'=>'0','text'=>TEXT_NEW_ACCOUNT_PENDING_AWARD),array('id'=>'1','text'=>TEXT_NEW_ACCOUNT_EARNED_AWARD)),($value<0?'0':$value>0?'1':''),'onchange="UpdateAward()"').'<br />';
$content.=zen_draw_hidden_field('configuration_value',$value);

return $content;

}
function GetRewardPoints($products)
{
$reward_points=0;
if(REWARD_POINT_MODE=='0')
{
foreach($products as $product)
if(isset($product['qty']))
$reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])$product['qty'];
else
if(isset($product['quantity']))
$reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])
$product['quantity'];
else
if(isset($product['quantityField']))
$reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])*$product['quantityField'];
else
$reward_points="RP Error";
}
blah blah blah here is the end of the file to make sure I didn't screw up the ending.
//print_r($GLOBALS[$module]->output);
//$output_backup=$GLOBALS[$module]->output;
//$order_info_backup=$order->info;
//if(sizeof($GLOBALS[$module]->output)==0)
//$GLOBALS[$module]->process();
for($loop=0;$loop<sizeof($GLOBALS[$module]->output);$loop++)
if(zen_not_null($GLOBALS[$module]->output[$loop]['value']))
$value+=$GLOBALS[$module]->output[$loop]['value'];

    //$GLOBALS[$module]->output=$output_backup; 
    //$order->info=$order_info_backup; 
} 
return $value; 

}
*/
?>

> 
> So with all of this done.  
> 
> If it has been done right. 
>  
> I go into reward points admin.  Transfer 35 points from pending to earned.  
> 
> I generate this log:
> [29-Mar-2014 12:33:00] 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
> 
> Now I know I'm not the most computer literate person.  But I downloaded a fresh version yesterday.  So if my copy was bad I had the newest version available.  I have confirmed files located in the correct spot.  Made and confirmed the change to the function file.  Yet I'm still getting this error.  If someone is willing to look at my actual files and confirm I'm not crazy please let me know.  I know you all are frustrated and I am as well.  
> 
> Thank you for all your help Diva Vocals.  I didn't mind the caps or bold text or anything else you throw my way if it fixes the problem!  I'm a big boy and can take a few capitalized words. :)

You've added the right code to the WRONG spot in the file.. and hence created a BRAND NEW error.. :smile:

You need to add the required code BELOW the LAST section of the original code. The last section looks like this:

/*
function SetRewardPointDiscountTypeFunction($value,$key='')
{
require('includes/javascript/reward_points.js');

$content='<br />';

$content.='<strong>'.TEXT_NEW_ACCOUNT_AWARD_PROMPT.'</strong> '.zen_draw_checkbox_field('allow_award','',$value!=0,0,'onchange="UpdateAward()"');
$content.=zen_draw_input_field('award_points',($value==0?'':abs($value)),'onchange="UpdateAward()"').' '.zen_draw_pull_down_menu('award_id',array(array('id'=>'0','text'=>TEXT_NEW_ACCOUNT_PENDING_AWARD),array('id'=>'1','text'=>TEXT_NEW_ACCOUNT_EARNED_AWARD)),($value<0?'0':$value>0?'1':''),'onchange="UpdateAward()"').'<br />';
$content.=zen_draw_hidden_field('configuration_value',$value);

return $content;

}
*/


You added the code JUST ABOVE the ```
*/
``` and that is the issue..
The last section of the original code is commented out, and by adding the new code WHERE you added it you inadvertently UN-COMMENTED it..

upload a fresh copy of the admin file and make your edits again.. Remember to add the code between the ```
*/
``` and the ```
?>

BTW, you can remove the

?>
``` from the end of the file..

Feels like you are almost there..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

29 Mar 2014, 5:19 PM
#2406
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

Here is a copy of my admin folder that I compressed in cpanel then downloaded and removed the extra files. So this is how my online website directory actually looks and the contents of each of those files.

Attachment #13928

29 Mar 2014, 5:22 PM
#2407
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

Thank you so much!!!! I just downloaded my whole admin sit and posted it. As it turns out it's just a silly mistake from my misunderstanding where to post! Thank you! I will make those changes in about 30 minutes and cross my fingers it works! I'm sure it will though.

thank you again!!!

29 Mar 2014, 5:46 PM
#2408
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Reward Points Module for ZC v13x

southshorepizza:

Thank you for all your help Diva Vocals. I didn't mind the caps or bold text or anything else you throw my way if it fixes the problem! I'm a big boy and can take a few capitalized words. :)and thanks for reading my WORDS and not assuming I FELT a particular way when I posted them.. It's NEVER personal here.. just business! :smile:

southshorepizza:

Thank you so much!!!! I just downloaded my whole admin sit and posted it. As it turns out it's just a silly mistake from my misunderstanding where to post! Thank you! I will make those changes in about 30 minutes and cross my fingers it works! I'm sure it will though.

thank you again!!!Yep.. placing the right code in the wrong place can lead to some ugly results.. :) Thanks for sticking with this, and for providing DETAILED information.. that's the best way you can help us help you.. :smile: feels like you're almost there on this one though.. You should have a slice to celebrate!

I'll take a meatballs and mushrooms pie with extra cheese and a pitcher of cold beer to wash it down.. :laugh:

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

29 Mar 2014, 6:08 PM
#2409
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

I changed the file to read:

/*
function SetRewardPointDiscountTypeFunction($value,$key='')
{
    require('includes/javascript/reward_points.js');
    
    $content='<br />';
    
    $content.='<strong>'.TEXT_NEW_ACCOUNT_AWARD_PROMPT.'</strong> '.zen_draw_checkbox_field('allow_award','',$value!=0,0,'onchange="UpdateAward()"');
    $content.=zen_draw_input_field('award_points',($value==0?'':abs($value)),'onchange="UpdateAward()"').' '.zen_draw_pull_down_menu('award_id',array(array('id'=>'0','text'=>TEXT_NEW_ACCOUNT_PENDING_AWARD),array('id'=>'1','text'=>TEXT_NEW_ACCOUNT_EARNED_AWARD)),($value<0?'0':$value>0?'1':''),'onchange="UpdateAward()"').'<br />';
    $content.=zen_draw_hidden_field('configuration_value',$value);

    return $content;
}
*/
function GetRewardPoints($products) 
{ 
    $reward_points=0; 
    if(REWARD_POINT_MODE=='0') 
    { 
        foreach($products as $product) 
         if(isset($product['qty'])) 
          $reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])*$product['qty']; 
         else 
          if(isset($product['quantity'])) 
           $reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])*$product['quantity']; 
          else 
           if(isset($product['quantityField'])) 
            $reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])*$product['quantityField']; 
          else 
           $reward_points="RP Error"; 
    } 
    else 
    { 
        global $order; 
         
        $GlobalRewardPointRatio=GetGlobalRewardPointRatio(); 
        if(isset($_SESSION['cart'])) 
         $reward_points=zen_round($_SESSION['cart']->show_total()*$GlobalRewardPointRatio-REWARD_POINTS_ROUNDING,0); 
          
        if(isset($order) && isset($order->info)) 
         if(REWARD_POINTS_ALLOW_TOTAL=='0' && isset($order->info['subtotal'])) 
          $reward_points=zen_round($order->info['subtotal']*$GlobalRewardPointRatio-REWARD_POINTS_ROUNDING,0); 
         else 
          if(isset($order->info['total'])) 
           $reward_points=zen_round($order->info['total']*$GlobalRewardPointRatio-REWARD_POINTS_ROUNDING,0); 
    } 
    return $reward_points; 
} 

function GetProductRewardPoints($products_id,$attributes=null) 
{ 
    global $db; 
    $reward_price=0; 
     
    if(zen_get_products_price_is_free($products_id)==false || REWARD_POINTS_ALLOW_ON_FREE=='1') // Allow RP on free items (Admin settable) 
    { 
        $sql = "SELECT prp.point_ratio*p.products_price AS reward_points, prp.point_ratio, p.products_price, p.products_priced_by_attribute  
                FROM ".TABLE_REWARD_MASTER." prp, ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c  
                WHERE p.products_id='" . $products_id . "' 
                AND p2c.products_id='" . $products_id . "' 
                AND ((prp.scope_id=p.products_id AND prp.scope='".SCOPE_PRODUCT."')  
                OR (p.products_id=p2c.products_id AND prp.scope_id=p2c.categories_id AND prp.scope='".SCOPE_CATEGORY."') 
                OR (prp.scope='".SCOPE_GLOBAL."')) 
                ORDER BY prp.scope DESC LIMIT 1;"; 
     
        $result=$db->Execute($sql); 
     
        if($result) 
        { 
            if(zen_has_product_attributes($products_id,'false') && !$attributes) 
             $reward_price=zen_get_products_base_price($products_id); 
            else 
             $reward_price=$result->fields['products_price']; 
              
            //echo '['.$reward_price.'='; 
            //print_r($attributes); 
            //echo ']'; 
             
            $special_price=zen_get_products_special_price($products_id); 
             
            if(REWARD_POINTS_SPECIAL_ADJUST=='1' && $special_price && !$attributes) 
             $reward_price=$special_price; 
         
            // Calculate attribute pricing 
            //if($result->fields['products_priced_by_attribute']=='1' && $attributes!=null) 
            if($attributes!=null) 
             if(isset($attributes[0]['option_id'])) 
              foreach($attributes as $attribute) 
               $reward_price+=CalculateRewardPointsOnAttribute($products_id,$attribute['option_id'],$attribute['value_id']); 
             else 
              foreach($attributes as $option_id => $value_id) 
               $reward_price+=CalculateRewardPointsOnAttribute($products_id,$option_id,$value_id); 
        } 
    } 

    //echo '::'.$reward_price.', '.$result->fields['point_ratio'].', '.REWARD_POINTS_ROUNDING.'::'; 
    $reward_points=($reward_price*$result->fields['point_ratio'])-REWARD_POINTS_ROUNDING; 
    if($reward_points<0) 
     $reward_points=0; 
      
    return zen_round($reward_points,0); 
} 

function CalculateRewardPointsOnAttribute($products_id,$option_id,$value_id) 
{ 
    global $db; 
     
    if($attribute=$db->Execute("SELECT products_attributes_id, attributes_discounted, options_values_price, price_prefix FROM ".TABLE_PRODUCTS_ATTRIBUTES." WHERE products_id='".$products_id."' AND options_id='".$option_id."' AND options_values_id='".$value_id."';")) 
     if(REWARD_POINTS_SPECIAL_ADJUST=='1' && $attribute->fields['attributes_discounted']=='1') 
      $new_attributes_price=zen_get_discount_calc($products_id,$attribute->fields['products_attributes_id'],$attribute->fields['options_values_price'],1); 
     else  
      $new_attributes_price=$attribute->fields['options_values_price']; 
       
    return ($attribute->fields['price_prefix']=='-'?-$new_attributes_price:$new_attributes_price); 
} 

function GetRedeemRatio($customers_id) 
{ 
    global $db; 
     
    $sql = "SELECT redeem_ratio  
            FROM ".TABLE_REWARD_MASTER." prp, ".TABLE_CUSTOMERS." as c 
            LEFT JOIN(".TABLE_GROUP_PRICING." as gp) ON (gp.group_id=c.customers_group_pricing) 
            WHERE c.customers_id='".(int)$customers_id."' 
            AND ((prp.scope_id='".$customers_id."' AND prp.scope='".SCOPE_CUSTOMER."') 
            OR (gp.group_id=c.customers_group_pricing AND prp.scope_id=gp.group_id AND scope='".SCOPE_GROUP."') 
            OR (prp.scope='".SCOPE_GLOBAL."')) 
            ORDER BY prp.scope DESC LIMIT 1;";  

    $result=$db->Execute($sql); 

    if($result) 
     return $result->fields['redeem_ratio']; 
    else 
     return 0; 
} 

function GetRewardPointsRedeemMaximum($order_total) 
{ 
    $redeem_ratio=GetRedeemRatio($_SESSION['customer_id']); 
    $order_total_points=zen_round($order_total/$redeem_ratio,0); 

    if((double)REWARD_POINTS_REDEEM_MAXIMUM>0) 
     if(strpos(REWARD_POINTS_REDEEM_MAXIMUM,"%")!==false) 
      return zen_round($order_total_points*((double)REWARD_POINTS_REDEEM_MAXIMUM/100),0); 
     else 
      if($order_total_points>REWARD_POINTS_REDEEM_MAXIMUM) 
       return zen_round(REWARD_POINTS_REDEEM_MAXIMUM,0); 

    return zen_round($order_total_points,0); 
} 

function GetCustomersRewardPoints($customers_id) 
{ 
    $result=GetCustomerRewardPointsRecord($customers_id); 
    if($result) 
     return (int)$result->fields['reward_points']; 
    else 
     return 0; 
} 

function GetCustomersPendingPoints($customers_id) 
{ 
    $result=GetCustomerRewardPointsRecord($customers_id); 
    if($result) 
     return (int)$result->fields['pending_points']; 
    else 
     return 0; 
} 

function GetCustomersLastOrderID($customers_id) 
{ 
    global $db; 
     
    $orders_lookup_query="SELECT orders_id FROM ".TABLE_ORDERS." WHERE customers_id = '".(int)$customers_id."' ORDER BY orders_id DESC LIMIT 1"; 
    $orders_lookup = $db->Execute($orders_lookup_query); 
    if(isset($orders_lookup->fields)) 
     return $orders_lookup->fields['orders_id']; 
    else 
     return 0; 
} 

function ExtractNumber($str) 
{ 
    if(preg_match("/^[0-9]*[\.]{1}[0-9-]+$/",$str,$match)) 
     return floatval($match[0]); 
    else 
     return floatval($str);     
} 

function GetOrderTotalsArray($called_by) 
{ 
    global $order_total_modules; 
     
    $order_total_array = array(); 
    $modules=$order_total_modules->modules; 
    if(is_array($modules)) 
    { 
        reset($modules); 
        while (list(,$value)=each($modules))  
        { 
            $class=substr($value, 0, strrpos($value, '.')); 
            if($class!=$called_by && isset($GLOBALS[$class])) 
            { 
                $output_backup=$GLOBALS[$class]->output; 
                if(sizeof($GLOBALS[$class]->output)==0) 
                 $GLOBALS[$class]->process(); 
                for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) 
                 if(zen_not_null($GLOBALS[$class]->output[$i]['title']) && zen_not_null($GLOBALS[$class]->output[$i]['text'])) 
                  $order_total_array[]=array('code' => $GLOBALS[$class]->code,'title' => $GLOBALS[$class]->output[$i]['title'],'text' => $GLOBALS[$class]->output[$i]['text'],'value' => $GLOBALS[$class]->output[$i]['value'],'sort_order' => $GLOBALS[$class]->sort_order); 
                   
                $GLOBALS[$class]->output=$output_backup; 
            } 
        } 
    } 
    return $order_total_array; 
} 

function GetRewardPointAdvancedCalculateValue() 
{ 
    $value=0; 
     
    $module_list=GetRewardPointAdvancedCalculateTable(); 
     
    foreach($module_list as $module) 
     if($module['action']=="Subtract") 
      $value-=GetOrderTotalValue($module['module']); 
     else 
      $value+=GetOrderTotalValue($module['module']); 
       
    return $value; 
} 

function GetOrderTotalValue($module) 
{ 
    global $order; 
    $value=0; 
     
    if(isset($GLOBALS[$module]) && isset($order->info)) 
    { 
        //print_r($GLOBALS[$module]->output); 
        //$output_backup=$GLOBALS[$module]->output; 
        //$order_info_backup=$order->info; 
        //if(sizeof($GLOBALS[$module]->output)==0) 
         //$GLOBALS[$module]->process(); 
        for($loop=0;$loop<sizeof($GLOBALS[$module]->output);$loop++) 
         if(zen_not_null($GLOBALS[$module]->output[$loop]['value'])) 
          $value+=$GLOBALS[$module]->output[$loop]['value']; 
                   
        //$GLOBALS[$module]->output=$output_backup; 
        //$order->info=$order_info_backup; 
    } 
    return $value; 
}  
?>

I still get the error:
[29-Mar-2014 14:05:38] 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

Perhaps you could just attach the file with changes?? I lost my patience on this hours ago! I'm sure your ready to know some sense into me! :bangin:

29 Mar 2014, 9:06 PM
#2410
countrycharm avatar

countrycharm

Totally Zenned

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

Re: Reward Points Module for ZC v13x

southshorepizza:

I changed the file to read:

/*
function SetRewardPointDiscountTypeFunction($value,$key='')
{
require('includes/javascript/reward_points.js');

$content='<br />';

$content.='<strong>'.TEXT_NEW_ACCOUNT_AWARD_PROMPT.'</strong> '.zen_draw_checkbox_field('allow_award','',$value!=0,0,'onchange="UpdateAward()"');
$content.=zen_draw_input_field('award_points',($value==0?'':abs($value)),'onchange="UpdateAward()"').' '.zen_draw_pull_down_menu('award_id',array(array('id'=>'0','text'=>TEXT_NEW_ACCOUNT_PENDING_AWARD),array('id'=>'1','text'=>TEXT_NEW_ACCOUNT_EARNED_AWARD)),($value<0?'0':$value>0?'1':''),'onchange="UpdateAward()"').'<br />';
$content.=zen_draw_hidden_field('configuration_value',$value);

return $content;

}
/
function GetRewardPoints($products)
{
$reward_points=0;
if(REWARD_POINT_MODE=='0')
{
foreach($products as $product)
if(isset($product['qty']))
$reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])
$product['qty'];
else
if(isset($product['quantity']))
$reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])$product['quantity'];
else
if(isset($product['quantityField']))
$reward_points+=GetProductRewardPoints($product['id'],$product['attributes'])
$product['quantityField'];
else
$reward_points="RP Error";
}
else
{
global $order;

    $GlobalRewardPointRatio=GetGlobalRewardPointRatio(); 
    if(isset($_SESSION['cart'])) 
     $reward_points=zen_round($_SESSION['cart']->show_total()*$GlobalRewardPointRatio-REWARD_POINTS_ROUNDING,0); 
      
    if(isset($order) && isset($order->info)) 
     if(REWARD_POINTS_ALLOW_TOTAL=='0' && isset($order->info['subtotal'])) 
      $reward_points=zen_round($order->info['subtotal']*$GlobalRewardPointRatio-REWARD_POINTS_ROUNDING,0); 
     else 
      if(isset($order->info['total'])) 
       $reward_points=zen_round($order->info['total']*$GlobalRewardPointRatio-REWARD_POINTS_ROUNDING,0); 
} 
return $reward_points; 

}

function GetProductRewardPoints($products_id,$attributes=null)
{
global $db;
$reward_price=0;

if(zen_get_products_price_is_free($products_id)==false || REWARD_POINTS_ALLOW_ON_FREE=='1') // Allow RP on free items (Admin settable) 
{ 
    $sql = "SELECT prp.point_ratio*p.products_price AS reward_points, prp.point_ratio, p.products_price, p.products_priced_by_attribute  
            FROM ".TABLE_REWARD_MASTER." prp, ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c  
            WHERE p.products_id='" . $products_id . "' 
            AND p2c.products_id='" . $products_id . "' 
            AND ((prp.scope_id=p.products_id AND prp.scope='".SCOPE_PRODUCT."')  
            OR (p.products_id=p2c.products_id AND prp.scope_id=p2c.categories_id AND prp.scope='".SCOPE_CATEGORY."') 
            OR (prp.scope='".SCOPE_GLOBAL."')) 
            ORDER BY prp.scope DESC LIMIT 1;"; 
 
    $result=$db->Execute($sql); 
 
    if($result) 
    { 
        if(zen_has_product_attributes($products_id,'false') && !$attributes) 
         $reward_price=zen_get_products_base_price($products_id); 
        else 
         $reward_price=$result->fields['products_price']; 
          
        //echo '['.$reward_price.'='; 
        //print_r($attributes); 
        //echo ']'; 
         
        $special_price=zen_get_products_special_price($products_id); 
         
        if(REWARD_POINTS_SPECIAL_ADJUST=='1' && $special_price && !$attributes) 
         $reward_price=$special_price; 
     
        // Calculate attribute pricing 
        //if($result->fields['products_priced_by_attribute']=='1' && $attributes!=null) 
        if($attributes!=null) 
         if(isset($attributes[0]['option_id'])) 
          foreach($attributes as $attribute) 
           $reward_price+=CalculateRewardPointsOnAttribute($products_id,$attribute['option_id'],$attribute['value_id']); 
         else 
          foreach($attributes as $option_id => $value_id) 
           $reward_price+=CalculateRewardPointsOnAttribute($products_id,$option_id,$value_id); 
    } 
} 

//echo '::'.$reward_price.', '.$result->fields['point_ratio'].', '.REWARD_POINTS_ROUNDING.'::'; 
$reward_points=($reward_price*$result->fields['point_ratio'])-REWARD_POINTS_ROUNDING; 
if($reward_points<0) 
 $reward_points=0; 
  
return zen_round($reward_points,0); 

}

function CalculateRewardPointsOnAttribute($products_id,$option_id,$value_id)
{
global $db;

if($attribute=$db->Execute("SELECT products_attributes_id, attributes_discounted, options_values_price, price_prefix FROM ".TABLE_PRODUCTS_ATTRIBUTES." WHERE products_id='".$products_id."' AND options_id='".$option_id."' AND options_values_id='".$value_id."';")) 
 if(REWARD_POINTS_SPECIAL_ADJUST=='1' && $attribute->fields['attributes_discounted']=='1') 
  $new_attributes_price=zen_get_discount_calc($products_id,$attribute->fields['products_attributes_id'],$attribute->fields['options_values_price'],1); 
 else  
  $new_attributes_price=$attribute->fields['options_values_price']; 
   
return ($attribute->fields['price_prefix']=='-'?-$new_attributes_price:$new_attributes_price); 

}

function GetRedeemRatio($customers_id)
{
global $db;

$sql = "SELECT redeem_ratio  
        FROM ".TABLE_REWARD_MASTER." prp, ".TABLE_CUSTOMERS." as c 
        LEFT JOIN(".TABLE_GROUP_PRICING." as gp) ON (gp.group_id=c.customers_group_pricing) 
        WHERE c.customers_id='".(int)$customers_id."' 
        AND ((prp.scope_id='".$customers_id."' AND prp.scope='".SCOPE_CUSTOMER."') 
        OR (gp.group_id=c.customers_group_pricing AND prp.scope_id=gp.group_id AND scope='".SCOPE_GROUP."') 
        OR (prp.scope='".SCOPE_GLOBAL."')) 
        ORDER BY prp.scope DESC LIMIT 1;";  

$result=$db->Execute($sql); 

if($result) 
 return $result->fields['redeem_ratio']; 
else 
 return 0; 

}

function GetRewardPointsRedeemMaximum($order_total)
{
$redeem_ratio=GetRedeemRatio($_SESSION['customer_id']);
$order_total_points=zen_round($order_total/$redeem_ratio,0);

if((double)REWARD_POINTS_REDEEM_MAXIMUM>0) 
 if(strpos(REWARD_POINTS_REDEEM_MAXIMUM,"%")!==false) 
  return zen_round($order_total_points*((double)REWARD_POINTS_REDEEM_MAXIMUM/100),0); 
 else 
  if($order_total_points>REWARD_POINTS_REDEEM_MAXIMUM) 
   return zen_round(REWARD_POINTS_REDEEM_MAXIMUM,0); 

return zen_round($order_total_points,0); 

}

function GetCustomersRewardPoints($customers_id)
{
$result=GetCustomerRewardPointsRecord($customers_id);
if($result)
return (int)$result->fields['reward_points'];
else
return 0;
}

function GetCustomersPendingPoints($customers_id)
{
$result=GetCustomerRewardPointsRecord($customers_id);
if($result)
return (int)$result->fields['pending_points'];
else
return 0;
}

function GetCustomersLastOrderID($customers_id)
{
global $db;

$orders_lookup_query="SELECT orders_id FROM ".TABLE_ORDERS." WHERE customers_id = '".(int)$customers_id."' ORDER BY orders_id DESC LIMIT 1"; 
$orders_lookup = $db->Execute($orders_lookup_query); 
if(isset($orders_lookup->fields)) 
 return $orders_lookup->fields['orders_id']; 
else 
 return 0; 

}

function ExtractNumber($str)
{
if(preg_match("/^[0-9]*[.]{1}[0-9-]+$/",$str,$match))
return floatval($match[0]);
else
return floatval($str);
}

function GetOrderTotalsArray($called_by)
{
global $order_total_modules;

$order_total_array = array(); 
$modules=$order_total_modules->modules; 
if(is_array($modules)) 
{ 
    reset($modules); 
    while (list(,$value)=each($modules))  
    { 
        $class=substr($value, 0, strrpos($value, '.')); 
        if($class!=$called_by && isset($GLOBALS[$class])) 
        { 
            $output_backup=$GLOBALS[$class]->output; 
            if(sizeof($GLOBALS[$class]->output)==0) 
             $GLOBALS[$class]->process(); 
            for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) 
             if(zen_not_null($GLOBALS[$class]->output[$i]['title']) && zen_not_null($GLOBALS[$class]->output[$i]['text'])) 
              $order_total_array[]=array('code' => $GLOBALS[$class]->code,'title' => $GLOBALS[$class]->output[$i]['title'],'text' => $GLOBALS[$class]->output[$i]['text'],'value' => $GLOBALS[$class]->output[$i]['value'],'sort_order' => $GLOBALS[$class]->sort_order); 
               
            $GLOBALS[$class]->output=$output_backup; 
        } 
    } 
} 
return $order_total_array; 

}

function GetRewardPointAdvancedCalculateValue()
{
$value=0;

$module_list=GetRewardPointAdvancedCalculateTable(); 
 
foreach($module_list as $module) 
 if($module['action']=="Subtract") 
  $value-=GetOrderTotalValue($module['module']); 
 else 
  $value+=GetOrderTotalValue($module['module']); 
   
return $value; 

}

function GetOrderTotalValue($module)
{
global $order;
$value=0;

if(isset($GLOBALS[$module]) && isset($order->info)) 
{ 
    //print_r($GLOBALS[$module]->output); 
    //$output_backup=$GLOBALS[$module]->output; 
    //$order_info_backup=$order->info; 
    //if(sizeof($GLOBALS[$module]->output)==0) 
     //$GLOBALS[$module]->process(); 
    for($loop=0;$loop<sizeof($GLOBALS[$module]->output);$loop++) 
     if(zen_not_null($GLOBALS[$module]->output[$loop]['value'])) 
      $value+=$GLOBALS[$module]->output[$loop]['value']; 
               
    //$GLOBALS[$module]->output=$output_backup; 
    //$order->info=$order_info_backup; 
} 
return $value; 

}
?>

> I still get the error:
> [29-Mar-2014 14:05:38] 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
> 
> Perhaps you could just attach the file with changes??  I lost my patience on this hours ago! I'm sure your ready to know some sense into me! :bangin:

You are right, in the upgrade folder there is no includes/functions/extra_functions folder. The upgrade folder is only for if you are upgrading from zen cart version 1.3.9.
Why are you adding any code in the first place. Do you have edit orders installed on your site? If you don't have edit orders installed then then reward points will work right out of the box. The code modification is only if you have edit orders installed a long with this module.

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

29 Mar 2014, 9:10 PM
#2411
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

Yes I have edited orders. But I don't know why that affects when I change points from pending to earned.
I am having problems upgrading to Edit orders 4.0 from 3.1 because the rewards points module isn't working properly. But again the error log I keep posting is from changing points pending to points earned! Something I would imagine I could do with or without edited orders module.

29 Mar 2014, 9:32 PM
#2412
countrycharm avatar

countrycharm

Totally Zenned

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

Re: Reward Points Module for ZC v13x

southshorepizza:

Yes I have edited orders. But I don't know why that affects when I change points from pending to earned.
I am having problems upgrading to Edit orders 4.0 from 3.1 because the rewards points module isn't working properly. But again the error log I keep posting is from changing points pending to points earned! Something I would imagine I could do with or without edited orders module.

Here just download the functions/extra_functions/reward_points_functions.php zip, unzip it and upload it to your admin/includes/functions/extra_functions folder. I think it will be much easier for you.

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

29 Mar 2014, 9:38 PM
#2413
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

I don't think that is the issue. I just downloaded that file and uploaded it to the site.
I got this:
[29-Mar-2014 17:36:59] 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

Sorry it didn't work.

1 Apr 2014, 6:19 PM
#2414
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:

... PHP Fatal error: 1064:You have an error in your SQL syntax; ... 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; ...
I believe an issue with a missing customer_id in the SQL statement has been reported before in this thread... Not sure if a solution was posted... If you install this modification by lat9, you can track down where in the reward points module the problematic SQL query is being built.

Hopefully once we all know where the SQL statement causing the error is being created, someone will be able to help further diagnose and fix the issue.

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

4 Apr 2014, 7:50 AM
#2415
mnitescu avatar

mnitescu

New Zenner

Join Date:
Dec 2011
Location:
Romania
Posts:
16
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

hi there
I have the 1.3.9. version of reward points.
Now I updgraded from zen cart 1.3.9. to 1.5.1 and used the 1.5.0 upgrade sql.
So I have the 1.3.9 version of reward points with 1.5.0 upgrade, which I think is not quite right.
When I go to Customer>Reward Points and try to edit anything all I get is a blank page.
What should I do?

4 Apr 2014, 1:23 PM
#2416
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Reward Points Module for ZC v13x

mnitescu:

What should I do?

Blank page = ERROR LOG

Go to your error log and tell us what the error log says..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

4 Apr 2014, 9:48 PM
#2417
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

lhungil:

I believe an issue with a missing customer_id in the SQL statement has been reported before in this thread... Not sure if a solution was posted... If you install this modification by lat9, you can track down where in the reward points module the problematic SQL query is being built.

Hopefully once we all know where the SQL statement causing the error is being created, someone will be able to help further diagnose and fix the issue.
I have installed it and will report back soon. Thank you for this tip!

6 Apr 2014, 12:22 AM
#2418
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

I installed the modification by lat9 as suggested. Now my error log reads:

[05-Apr-2014 04:20:36] 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; ==> (as called by) /home4/xxxx/public_html/order/admin/customers_reward_points.php on line 358 <== in /home4/xxxx/public_html/order/includes/classes/db/mysql/query_factory.php on line 130

Any help would be greatly appreciated!

28 Apr 2014, 6:44 PM
#2419
kelly60 avatar

kelly60

New Zenner

Join Date:
Feb 2014
Location:
southern Oregon
Posts:
21
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

I can't figure out why the reward points aren't applying to my customers orders. I went through every section of the Reward Points configuration in my admin panel under Configuration. The reward point value is showing up correctly next to each product but in my Customers/Reward Points section they are not showing any totals. Any help is appreciated! Thank you!

29 Apr 2014, 5:03 PM
#2420
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:

... PHP Fatal error: 1064:You have an error in your SQL syntax; ... /admin/customers_reward_points.php on line 358 ...

Any help would be greatly appreciated!
Looks like the code in that file ASSUMES a valid customer id will be passed in the URL when certain actions are performed. If the customer id is not valid when trying to edit, update, or process reward points this error will occur.

As a temporary way to avoid this error, one "could" wrap the entire switch statement (performing the action - starts around line 318) with something similar to:

if(zen_not_null($current_customer)) {
```Closing the if statement after the switch (around line 381) using something similar to: ```
} else { echo '<div class="alert">No Customer (or invalid customer) selected. No action performed!</div>'; }

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