thanks - very much appreciated!
Printable View
thanks - very much appreciated!
Has this been discussed already: I am running the latest version on 1.5.1, but if I put a SPECIAL PRICE on an item, the module is still rewarding points on the original price.
For example, let's say that I have an item for $35.00. Normally, if you add this item to your cart, you would earn +4 Points.
Now if I go to Product's Price Manager, then click INSTALL on the "Special Price Info", and set a price for $4.95, then I'm still seeing the module reward the same +4 points to this item!
In other words, it's giving away money based on the original price.
NOW HERE'S THE KICKER: Under Configuration --> Reward Point Configuration --> Adjust Reward Points for Sales/Specials, I have that value set to "1".
So I have no idea why it's still calculating points based on the normal price, and not the Special Price Info.
I can't find the uninstall directions for the module (a client wants this removed and it was installed by someone else). I found the install.sql and remove_multiple_config_items.sql files, do I just need to remove them? I know I need to remove the code from tpl_product_info_display.php but is there anything else I need to do other than remove the reward point files???
I have the Reward Point mod and Edit Orders installed on v1.51, it seems to work well. Until I try to update an order. When I change that the order to delivered (or edit an order), I get a blank screen. The change is actually saved but I have to hit the back button on my browser to get out of the blank screen. Any idea how to fix this?
This is from the error log:
[02-Oct-2013 16:41:37] PHP Fatal error: Call to undefined function GetRewardPoints() in /home/scrappin/public_html/newstore/includes/modules/order_total/ot_reward_points_display.php on line 40
I am having this exact same error. Using ZC 1.5.1, latest Edit Orders, Super Orders, and Reward Point Mod. Everything seemingly worked fine until installing Admin New Order plugin. All installation instructions were followed to the T and double checked. Anyone have any suggestions?
Hi All,
I tried to search this thread but couldn't find a work around, take a look at the order below:
1 x XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $156.78
3 x XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $83.22
---------
Sub-Total: $240.00
Free Shipping Options (Free Shipping): $0.00
Value of Redeemed Reward Points: -$0.40
Total: $239.61
The problem is that the total supposed to be $239.60 not $239.61. Looking further into this, the Customer had 79 points and I have my ratio setup as .005 so when you convert you get $0.395 I am not sure how this simple calculation is happening in the module but something doesn't seem correct, perhaps the Value of Redeemed Reward Points should be $0.39 but if you look above it shows $0.40 but when this get subtracted from subtotal it's off by a penny.
I know all my products are rounded to 2 decimal points and I am able to verify this, is there a way to fix this issue.
I am using ZC 1.50.
thank you
I need to get the ADMIN>CUSTOMERS>REWARD POINTS table to display email address field. I am trying to modify admin/customers_reward_points.php. I added:
When I did this I broke the page with error on line 239. Could someone please help me with this. PHP is not my strength.Code:<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="75%" height="1px"></td>
<td width="25%" height="1px"></td>
</tr>
<tr>
<td valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMER_ID; ?></td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMER_LAST_NAME; ?></td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMER_FIRST_NAME; ?></td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMER_EMAIL_ADDRESS; ?</td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMER_PENDING_POINTS; ?></td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMER_EARNED_POINTS; ?></td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMER_PRICING_GROUP; ?></td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_GROUP_REDEEM_RATIO; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?></td>
</tr>
<?php
if(isset($_SESSION['search']))
$where=" WHERE (c.customers_lastname LIKE '%".$_SESSION['search']."%' OR c.customers_firstname LIKE '%".$_SESSION['search']."%' OR c.customers_id LIKE '%".$_SESSION['search']."%' OR c.customers_email_address LIKE '%".$_SESSION['search']."%')";
else
if(isset($_SESSION['customer_sort_index']))
if($_SESSION['customer_sort_order']==1)
$where=" WHERE c.customers_firstname LIKE '".$_SESSION['customer_sort_index']."%'";
else
$where=" WHERE c.customers_lastname LIKE '".$_SESSION['customer_sort_index']."%'";
else
$where="";
switch($_SESSION['customer_sort_order'])
{
case (0):
$order_by=" ORDER BY c.customers_lastname";
break;
case (1):
$order_by=" ORDER BY c.customers_firstname, c.customers_lastname";
break;
case (2):
$order_by=" ORDER BY c.customers_id, c.customers_lastname";
break;
case (3):
$order_by=" ORDER BY gp.group_name, c.customers_lastname";
break;
case (4):
$order_by=" ORDER BY r.pending_points DESC, c.customers_lastname";
break;
case (5):
$order_by=" ORDER BY r.reward_points DESC, c.customers_lastname";
break;
case (6):
$order_by=" ORDER BY o.date_purchased DESC, c.customers_lastname";
break;
}
$group_by="";
$limit=" LIMIT ".REWARD_POINTS_CUSTOMER_LIMIT;
$customer_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, c.customers_group_pricing, r.pending_points, r.reward_points, gp.group_name, rm.redeem_ratio from ".TABLE_CUSTOMERS." as c LEFT JOIN (".TABLE_REWARD_CUSTOMER_POINTS." as r) ON (r.customers_id=c.customers_id) LEFT JOIN(".TABLE_GROUP_PRICING." as gp) ON (gp.group_id=c.customers_group_pricing) LEFT JOIN(".TABLE_REWARD_MASTER." as rm) ON ((c.customers_group_pricing!=0 AND rm.scope=".SCOPE_GROUP." AND rm.scope_id=c.customers_group_pricing) OR (c.customers_group_pricing=0 AND rm.scope=".SCOPE_GLOBAL." AND rm.scope_id=0))".$index.$where.$group_by.$order_by.$limit.";";
//echo $customer_query_raw;
$customers = $db->Execute($customer_query_raw);
while (!$customers->EOF)
{
//$redeem_points=GetRewardPointRecord(SCOPE_GROUP,$customers->fields['customers_group_pricing']);
if(isset($_GET['id']) && $customers->fields['customers_id']==$_GET['id'])
{
echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\''.zen_href_link(FILENAME_ADMIN_CUSTOMER_REWARD_POINTS,'id='.$customers->fields['customers_id'].'&action=edit').'\'">'."\n";
$current_customer=$customers->fields;
}
else
echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_ADMIN_CUSTOMER_REWARD_POINTS,'id='.$customers->fields['customers_id'].'&action=edit').'\'">'."\n";
?>
<td class="dataTableContent"><?php echo $customers->fields['customers_id']; ?></td>
<td class="dataTableContent"><?php echo $customers->fields['customers_lastname']; ?></td>
<td class="dataTableContent"><?php echo $customers->fields['customers_firstname']; ?></td>
<td class="dataTableContent"><?php echo $customers->fields['customers_email_address']; ?></td>
<td class="dataTableContent"><?php echo (int)$customers->fields['pending_points']; ?></td>
<td class="dataTableContent"><?php echo (int)$customers->fields['reward_points']; ?></td>
<td class="dataTableContent"><?php echo CheckText($customers-
Thank you!
I found the missing ">" in the line :Code:<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMER_EMAIL_ADDRESS; ?</td>
Does this module work with 1.5.1 or is it still to be tested?
The reason I asked is that I have installed it on 1.5.1 and it works great when people purchase via Paypal but not when they purchase via Nochex Payment Module.
Anyone else had this issue?
I installed the latest version of the module on 1.5.0 and everything seems to work fine except customers never actually get their points. It shows them in the sidebox, but once the order is placed they don't actually get the points. They don't appear as pending or earned.
You can create any status name you like, It doesn't matter when you change the status the points should transfer. Look under admin/Reward Points Configuration/ Reward Point Status Track and choose the advance settings. Set the order status items that will trigger a transfer of the reward points.
Hi, I'm posting the solution to the problems addressed with Edit Order plugin.
Eg. If You Edit and order when you hit the update button you get a blank page and an error log reporting a Call to undefined function GetRewardPoints()
If You have installed both You need to add some function in the \admin\includes\functions\extra_functions\reward_points_functions.php
Just before the /* at the end add:
It should work now :smile:PHP Code:
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've a question about how it works with attributes.
I've products with attributes that change the price (i.e. Standard - Big (+10.00$) - etc. ) if I select different attributes the Rewarded points on the product pages don't change, yet if I add the product to cart, different attributes will change the price and the points in the cart will change as a result.
Should the points displayed change "on the fly" when i select different attributes? Or am I wrong?
If so, where should i look to find out why It doesen't work for me (i.e. which file care about the "on the fly" update?)?
Thanks
Thanks for the code above. It will benefit a lot of people who has the same problem with edit orders.
Your other problem I have no idea why it's not updating. I know there is a module Dynamic Price Updater that will update your price on the fly but it still will not change the points status when using attributes. if someone is inclined to find the problem they can update the module or share the code which adds the fixes, then it will be included..
You are welcome countrycharm, the point is that i don't know if it shoud update automatically or not. In a poste i read tha it should.. but i'm not sure.
As regards Dynamic Price Update It only take care of the price not of the Reward points, installing it or not doesn't chane anything.
quick question here: how can i NOT display the points on the product info page and only have the points calculate during the checkout?
Thank you in advance.
Remove this chunk of code from the /includes/templates/your_template/templates/tpl_product_info_display.php.
Around line number 147
PHP Code:
<!--bof Product Reward Points block -->
<h2 id="productRewardPoints" class="productRewardPoints">
<?php
/**
* display the product reward points
*/
include($template->get_template_dir('/tpl_product_reward_points.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_product_reward_points.php');
?>
</h2>
<!--eof Product Reward Points block -->
For the option to show rewards points or not in the product pages a solution could be this:
in includes/templates/YOUR_TEMPLATES/tpl_product_info_display.php find:
Modify in:PHP Code:
* display the product reward points
*/
include($template->get_template_dir('/tpl_product_reward_points.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_product_reward_points.php');
?>
</h2>
<!--eof Product Reward Points block -->
* display the product reward points
*/
if (SHOW_REWARD_POINTS_PRODUCT == '1')
{
include($template->get_template_dir('/tpl_product_reward_points.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_product_reward_points.php');
}
?>
</h2>
<!--eof Product Reward Points block -->
Then using Phpmyadmin or the zencart admin patch add the following:
Setting to 0 the new option will not show the points in the product pages, else if you set to 1 it will show points.PHP Code:
SELECT @cgi:=configuration_group_id FROM configuration_group WHERE configuration_group_title = 'Reward Points';
INSERT INTO configuration
(configuration_id ,configuration_title ,configuration_key ,configuration_value ,configuration_description ,configuration_group_id ,sort_order ,last_modified ,date_added ,use_function ,set_function)
VALUES (NULL , 'Show rewards point in Product Page', 'SHOW_REWARD_POINTS_PRODUCT', '0', 'Display Reward Points in the product page?<br />0= No<br />1= Yes', @cgi, '1', NULL, now(), NULL , 'zen_cfg_select_option(array(''0'', ''1''), ');
NOTE: Please check if it's all correct and there is not errors of any kind. If You think ity could be useful please add it to the modules ;-)
Hi again,
hard work bring issues as long as solutions ;-)
First the issue: I found that when i was going to the details of an order the Rewards point shown were always 0, but if you go on the invoice module the Rewards point magically appeared. Simply in the order details the point were not shown.
it seems that the problem could be with this line in /admin/order.php around line 666
If replaced with:PHP Code:
<td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $currencies->format($order->totals[$i]['value'], false) . '</td>' . "\n" .
all seems fine. Someone else got this error?PHP Code:
<td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $order->totals[$i]['text'] . '</td>' . "\n" .
Zencart 1.51
Reward Point 2.1b
Agree, i just find that solution but i'm yet testing it. If someone would like to try itand post a feedback i'll appreciate. :-)
Order Total Modules were designed to show prices added or subtracted from an order... While the changes mentioned earlier "may" work... They may also break pricing calculation for stores accepting more than one currency... The stock Zen Cart "/admin/order.php" uses the database entry for "value" (with any currency conversion and formatting) instead of "text".
Instead of removing the currency calculations from EVERY order total module, one should probably add a modification to "/admin/order.php" specifically targeting the "Reward Points display" order total module (and using "text" when this module is encountered)... If going this route, one would also need to add an exemption to cause "Edit Orders" to NOT load the "Reward Points display" module (so it does not edit this line)... Or add "special" handling to address the non-standard use of the "value" and "text" but the "Reward Points display" order total module.
The alternative is to stop using (and remove) the "Reward Points Display" order total module and add the reward points earned information directly to the various templates / pages involved. This avoids the issues caused by using the "orders_total" database table in a way not expected by the Zen Cart core code.
Alright, dug into this the subject a little deeper today. Looks like Zen Cart 1.5.x out of box does not allow one to view orders in the admin with a currency other than the store default... I remember a discussion of this somewhere on the forums in the past, but do not remember what was decided...
So your change should not make a difference for the majority of users of Zen Cart 1.5.x (only those who may have for some reason wanted to see localized pricing for a different country in the admin and made changes)... I still believe it would be even better to at least add some conditional code to check which "order total" module (in "/admin/orders.php") is being displayed and ONLY skip the format function on the "Reward Points display" order total module... Or replace the "Reward Points display" order total module completely.
I currently have many other ongoing projects, so will not be able to spend any time on this project. Just was browsing this thread (have poked in here from time to time since it crossed my path) and decided to share some thoughts.
I just installed this awesome plugin last night and it is working great except for one thing. I have changed it so that customers are going to get 5 points for each $1 spent. So under Catalog>Reward Points I have set the Global Rewards Point Settings to 5.0000. The problem is that customers are only getting 5 points per order. For example, one customer has spent $3 and only received 5 points. It should have been 15 points. When you are shopping though it shows in the sidebox how many points you have in your cart and it adds up all the points you have in your cart. If you have $3 in your cart is shows 15 points. I hope I'm explaining this right and you all understand me. I'm sure it's just a setting that I need to change but I just don't know which setting. Any help would be greatly appreciated.
Here are my settings under Configuration/Reward Points:
Reward Point Mode 0
Reward Point Sidebox Display 0
Reward Point Status Track Simple
Reward Point Sunrise Period 0
Reward Point Redeem Minimum 0
Reward Point Redeem Maximum 0
Reward Point Rounding 0.0
Max Transactions to Display in Customer Admin 12
Delete Old Reward Transactions Period 90
Adjust Reward Points for Sales/Specials 1
Allow Reward Points on Free Products 0
Allow Redeem of Reward Points on Order Total or Subtotal 1
Set Minimum Order Value to Redeem Points Against 0
Limit Maximum Customers on Listings 50
Display Products Reward Points When Zero 1
Set New Account Reward Points 5 points added to earned
Advanced Reward Point Calculation Rules Advanced Rules Enabled
Nobody has pending points. I just had another order and no points were added this time.
The configuration seems fine.
The last thing i can ask is if the modules under Modules/Order Total are installed, expecially:
Reward points
and one between Rewards Point earned and Rewards Points Tiered Discont
If it's all installed, I suggest that You uninstall and reinstall the module from scratch.
After setting all the way you want check if errors log are generated.
If not and hte module still wont work report the following thing:
Zencart version
If You have other modules installed othen then reward point, expecially if they modify total order
PHP version
Mysql version
I'm hoping very strongly that one of your clients require the integration of this module and Edit Order :lol::lol:
Just kidding :laugh:. The only thing that I would welcome it is that if you see an error in the codes i posted that could compromise the functionality of Edit Order please advise :D
Rewards point module broke last night. I tried reinstalling it. now I get the follow error log:
[26-Nov-2013 10:41:19] StoreRewardPoints called but SESSION['REWARD_POINTS_EARNED'] not found
I am on Zen-Cart 1.5.1 Latest rewards points module. It was working great. Not sure what happened. I have reinstalled a fresh copy overwriting the files. I have tried reinstalling from my backup site. Both have not fixed the problem. They did change the error log from:
[25-Nov-2013 22:54:49] 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
But just to be clear my current error log is:
[26-Nov-2013 10:41:19] StoreRewardPoints called but SESSION['REWARD_POINTS_EARNED'] not found
Thank for the help. It worked great since October 10th. So I started advertising it yesterday. :( Of course it stopped working hours later.
I went into admin and uninstalled the modules and then reinstalled. I did a test order and it seems to work. Any ideas what happened and how to avoid?
Although it applied the points to points pending so I could award them I also generated an error log.
[26-Nov-2013 11:18:06] 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
Today I have observed an order where points was added to total order value . Do you know if there is a bug or something to check ?
thx
Hi,
I was in the same situation as you, and I was thinking about your solution, which in some words is copy/paste the content /includes/functions/extra_functions/reward_points_functions.php into /admin//includes/funtions/extra_functions/reward_points_functions.php.
But I'm wondering...
1) This duplicates code, and that would be kind if an expert (as Ajeh or DrByte) could tell us if the admin side is not supposed to be aware of the /includes functions side ?
2) If so (which I suppose), where in this module do we miss the line that make the admin side know the other side functions ?
I think correcting this would be more elegant than duplicating code. :-)
3) If we get no answer, your solution could be a lot more shorter :
as function GetRewardPoints only calls function GetProductRewardPoints;
and function GetProductRewardPoints only calls function CalculateRewardPointsOnAttribute;
we only need to paste these 3 functions (I assume).
So pasting
must be enough.PHP Code:
<?php 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);
}
Thanks for reading
...Oops I just missed two functions
But I'm still wondering if an include or an include_once would work and would not be more elegant ?PHP Code:
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;
}
Hubert
I am generating the following error log:
[26-Nov-2013 11:18:06] 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
How do I fix this?
Thank you for your help
Where in the code does it control the order in which it is applied to an order? I have recently been required to have reward point resumptions calculated before tax so the redemption is deducted from the subtotal and then tax is calculated.
Does anyone know how to fix this? I have asked a couple times. Not sure if it's been missed or nobody has an answer.
I am generating the following error log:
[26-Nov-2013 11:18:06] 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
How do I fix this?
Thank you for your help
Don't have the answer, but I can SEE the issue..
A SQL query seems to be missing the customers_id value:
Hopefully someone knows where/how to correct the errant SQL query..Code: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;
Hello,
I've searched the forum and can't find an answer to this problem, but I hope someone can help out.
Here are my server details:
Server OS: Linux 2.6.32-458.18.1.lve1.2.39.el6.x86_64 , Database: MySQL 5.5.34-cll, HTTP Server: Apache, PHP Version: 5.3.28 (Zend: 2.3.0)
I am running Zen Cart 1.5.1
I installed the reward points module as a new installation. However, I got some errors when trying to run the sql from admin, so I ran it from PHPMyadmin instead. Afterwards, nearly everything seems to work OK - The Catalogue->Reward Points page works fine, the Customer->Reward Points page works fine, and when I make a purchase, I collect reward points - all good.
However, the Configuration->Reward Point Configuration page just creates a nearly blank page. I am assuming this is a database problem, but I'm not sure what might have gone wrong with the SQL.
Can anyone help please? Thank you.
No the admin is not supposed to automatically load all functions from the catalog. There are cases where the same exact functions operate differently or use different settings on the admin versus the catalog.
There are at least three approaches to solving this issue which avoid duplicate code (pick one):
- Create an auto_load file on the admin which loads the functions file from the catalog.
- Move all functions required by the order total class - inside the order total class.
- In the order total class do a check (IS_ADMIN / function_exists). If needed use include_once to load the functions file.
Hey everyone, working on a ZenCart install for a client but this extension has me stumped. The description of it says it allows the admins to add points manually to certain users. Where do I go in the admin panel to do this? I have checked the reward points settings and the customer settings but I can't find anything. Thanks.
I upgraded from Edit orders 3.0 to 4.1.3 last night. when I edit an order I get a blank page with the following log
[29-Jan-2014 14:00:27] PHP Fatal error: Call to undefined function getrewardpoints() in /home4/w57dsjmm/public_html/d132s/includes/modules/order_total/ot_reward_points_display.php on line 40
I tried the below suggestion and no luck. Anyone able to help me on this?
Thank you!
it's great module work perfect .
how change the color font in sidebox "No points earned yet on current order ..." from white to another color ?
u try to find in the css stylesheet_reward.css but no success.
thanks for help .
You probably should post your \admin\includes\functions\extra_functions\reward_points_functions.php file so folks can see what your code with the suggested edits looks like..
PLEASE make sure you use the forum tags for posting code: [ CODE ] [ /CODE ] (It's the # symbol on the post toolbar)
here is the file \admin\includes\functions\extra_functions\reward_points_functions.php
Thank you for the help!Code:<?php
/**
* File contains just the reward points functions (Admin side)
*
* @package classes
* @copyright Andrew Moore
*/
if(!defined('IS_ADMIN_FLAG'))
die('Illegal Access');
// Sync reward points status with orders everytime the function is loaded
global $db,$messageStack;;
// Update any reward point records where the corresponding order has been modified since the last reward history date
if($result=$db->Execute("SHOW TABLES LIKE '".TABLE_REWARD_STATUS_TRACK."';"))
if($result->RecordCount()>0)
{
if($result=$db->Execute("SELECT ph.*, o.orders_status FROM ".TABLE_REWARD_STATUS_TRACK." ph, ".TABLE_ORDERS." o WHERE ph.orders_id=o.orders_id AND ph.date<o.last_modified;"))
while(!$result->EOF)
{
UpdateOrderRewardPointsStatus($result->fields['orders_id'],$result->fields['orders_status']);
$result->MoveNext();
}
// Remove all reward point history records for deleted orders. Update customers pending points removing any deleted order with points still pending
if($result=$db->Execute("SELECT * FROM ".TABLE_REWARD_STATUS_TRACK." rs WHERE rs.`orders_id` NOT IN (SELECT `orders_id` FROM ".TABLE_ORDERS.") LIMIT 1;"))
if($result->RecordCount()>0)
if($db->Execute("UPDATE ".TABLE_REWARD_CUSTOMER_POINTS." rc SET `pending_points`=`pending_points`-IFNULL((SELECT SUM(`reward_points`) FROM ".TABLE_REWARD_STATUS_TRACK." ph WHERE ph.`customers_id`=rc.`customers_id` AND ph.`status`=0 AND ph.`orders_id` NOT IN (SELECT `orders_id` FROM ".TABLE_ORDERS.")),0);"))
$db->Execute("DELETE FROM ".TABLE_REWARD_STATUS_TRACK." WHERE `orders_id` NOT IN (SELECT `orders_id` FROM ".TABLE_ORDERS.");");
}
function GetGlobalRewardPointRatio()
{
return GetRewardPointField(FIELD_POINT_RATIO,SCOPE_GLOBAL);
}
function GetGlobalRewardBonusPoints()
{
return GetRewardPointField(FIELD_BONUS_POINTS,SCOPE_GLOBAL);
}
function GetCategoryRewardPointRatio($category_id)
{
return GetRewardPointField(FIELD_POINT_RATIO,SCOPE_CATEGORY,$category_id);
}
function GetCategoryRewardBonusPoints($category_id)
{
return GetRewardPointField(FIELD_BONUS_POINTS,SCOPE_CATEGORY,$category_id);
}
function GetProductRewardPointRatio($product_id)
{
return GetRewardPointField(FIELD_POINT_RATIO,SCOPE_PRODUCT,$product_id);
}
function GetProductRewardBonusPoints($product_id)
{
return GetRewardPointField(FIELD_BONUS_POINTS,SCOPE_PRODUCT,$product_id);
}
function GetRewardPointField($field,$scope,$id=0)
{
if(($result=GetRewardPointRecord($scope,$id))!=null)
return $result->fields[$field];
return null;
}
function GetRewardPointRecord($scope,$id=0)
{
global $db;
$sql="SELECT * FROM ".TABLE_REWARD_MASTER." WHERE scope='".$scope."' AND scope_id='".$id."';";
$result=$db->Execute($sql);
if($result->RecordCount()>0)
return $result;
else
return null;
}
function UpdateRewardPointRecord($scope,$id,$point_ratio,$bonus_points=0)
{
global $db;
$sql="INSERT INTO ".TABLE_REWARD_MASTER." SET scope='".$scope."', scope_id='".$id."', point_ratio='".$point_ratio."' ON DUPLICATE KEY UPDATE point_ratio='".$point_ratio."';";
$result=$db->Execute($sql);
}
function UpdateRedeemRatioRecord($scope,$id,$redeem_ratio)
{
global $db;
$sql="INSERT INTO ".TABLE_REWARD_MASTER." SET scope='".$scope."', scope_id='".$id."', redeem_ratio='".$redeem_ratio."' ON DUPLICATE KEY UPDATE redeem_ratio='".$redeem_ratio."';";
$result=$db->Execute($sql);
}
function DeleteRewardPointRecord($scope,$id=0)
{
global $db;
$sql="DELETE FROM ".TABLE_REWARD_MASTER." WHERE scope='".$scope."' AND scope_id='".$id."';";
$result=$db->Execute($sql);
}
function UpdateOrderRewardPointsStatus($order_id,$zc_status)
{
global $messageStack;
if(REWARD_POINTS_STATUS_TRACK=='') // Simple mode
if($zc_status!=1) // If status has changed from Pending
TransferCustomerPointsFromPending($order_id);
else
TransferCustomerPointsToPending($order_id);
else // Advanced mode
if(($record=GetLastRewardPointHistoryRecord($order_id)))
if(($state=GetState($zc_status))!=STATUS_IGNORE && $status_change=($record->fields['status']!=$state))
if($state==STATUS_PROCESSED)
TransferCustomerPointsFromPending($order_id);
else
TransferCustomerPointsToPending($order_id);
}
function TransferCustomerPointsFromPending($order_id)
{
global $messageStack;
if(($record=GetLastRewardPointHistoryRecord($order_id)) && $record->fields['status']==STATUS_PENDING)
{
$customer_id=$record->fields['customers_id'];
$reward_points=$record->fields['reward_points'];
$pending_points=-$reward_points;
UpdateCustomerRewardPoints($customer_id,$reward_points,$pending_points);
UpdateRewardPointHistoryRecord($customer_id,$order_id,$reward_points,STATUS_PROCESSED);
}
else
if(!$record)
$messageStack->add_session(WARNING_MISSING_RECORD.' '.$order_id, 'warning');
}
function TransferCustomerPointsToPending($order_id)
{
global $messageStack;
if(($record=GetLastRewardPointHistoryRecord($order_id)) && $record->fields['status']==STATUS_PROCESSED)
{
$customer_id=$record->fields['customers_id'];
$pending_points=$record->fields['reward_points'];
$reward_points=-$pending_points;
UpdateCustomerRewardPoints($customer_id,$reward_points,$pending_points);
UpdateRewardPointHistoryRecord($customer_id,$order_id,$pending_points,STATUS_PENDING);
}
else
if(!$record)
$messageStack->add_session(WARNING_MISSING_RECORD.' '.$order_id, 'warning');
}
function UpdateRewardPointHistoryRecord($customer_id,$order_id,$reward_points,$status)
{
global $db;
$sql="REPLACE INTO ".TABLE_REWARD_STATUS_TRACK." SET customers_id='".(int)$customer_id."', orders_id='".(int)$order_id."', date=NOW(), reward_points='".$reward_points."', status=".$status.";";
$db->Execute($sql);
}
function GetLastRewardPointHistoryRecord($order_id)
{
global $db;
$sql="SELECT * FROM ".TABLE_REWARD_STATUS_TRACK." WHERE orders_id='".$order_id."' ORDER BY date DESC LIMIT 1;";
$result=$db->Execute($sql);
if($result->RecordCount()>0)
return $result;
else
return null;
}
function GetCustomerRewardPointsRecord($customer_id)
{
global $db;
$sql="SELECT * FROM ".TABLE_REWARD_CUSTOMER_POINTS." WHERE customers_id='".$customer_id."';";
$result=$db->Execute($sql);
if($result->RecordCount()>0)
return $result;
else
return null;
}
function UpdateCustomerRewardPoints($customer_id,$reward_points,$pending_points)
{
global $db;
$sql="INSERT INTO ".TABLE_REWARD_CUSTOMER_POINTS." SET customers_id='".$customer_id."', reward_points='".$reward_points."', pending_points='".$pending_points."' ON DUPLICATE KEY UPDATE reward_points=reward_points+".$reward_points.", pending_points=pending_points+".$pending_points.";";
$db->Execute($sql);
}
function DeleteOrderRewardPoints($order_id)
{
global $db,$messageStack;
if(($record=GetLastRewardPointHistoryRecord($order_id)))
{
$customer_id=$record->fields['customers_id'];
$pending_points=0;
$reward_points=0;
if($record->fields['status']==STATUS_PENDING)
$pending_points=-$record->fields['reward_points'];
else
$reward_points=-$record->fields['reward_points'];
UpdateCustomerRewardPoints($customer_id,$reward_points,$pending_points);
$sql="DELETE IGNORE FROM ".TABLE_REWARD_STATUS_TRACK." WHERE orders_id='".(int)$order_id."';";
$db->Execute($sql);
}
else
$messageStack->add_session(WARNING_NO_REWARD_POINTS_FOUND_FOR_ORDER.' '.$order_id, 'warning');
}
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)";
$sunrise_subset=sprintf($subset,REWARD_POINTS_SUNRISE_PERIOD);
$housekeeping_subset=sprintf($subset,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.pending_points=cp.pending_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;");
}
function UseRewardPointStateFunction($value)
{
if($value=='')
{
return TEXT_SIMPLE_MODE;
}
else
{
$status_list=GetOrdersStatusList();
$earn_list=array();
$pend_list=array();
$size=count($status_list);
foreach($status_list as $status)
switch($status['state'])
{
case STATUS_PENDING:
$pend_list[]=$status['text'];
break;
case STATUS_PROCESSED:
$earn_list[]=$status['text'];
break;
}
return TEXT_SHORT_PENDING_STATE_NAME.': ['.implode(", ",$pend_list).'] '.TEXT_SHORT_EARNED_STATE_NAME.': ['.implode(", ",$earn_list).']';
}
}
function SetRewardPointStateFunction($value,$key='')
{
$status_list=GetOrdersStatusList();
$state_names=array(TEXT_PENDING_STATE_NAME,TEXT_EARNED_STATE_NAME,TEXT_IGNORE_STATE_NAME);
require('includes/javascript/reward_points.js');
$content='<br />';
$content.='<strong>'.TEXT_MODE_PROMPT.'</strong> '.zen_draw_pull_down_menu('mode_id',array(array('id'=>'0','text'=>TEXT_SIMPLE_MODE),array('id'=>'1','text'=>TEXT_ADVANCED_MODE)),($value==''?'0':'1'),'onchange="UpdateMode()"').'<br />';
$content.='<div id="AdvancedModeTable" style="display: '.($value==''?'none':'block').'"><br /><center><table width="90%" border="0" cellspacing="0" bgcolor="#d0d0d0"><tbody><tr><th> </th>';
$name_size=count($state_names);
for($s=0;$s<$name_size;$s++)
$content.='<th align="center">'.$state_names[$s].'</th>';
$content.='</tr>';
$size=count($status_list);
for($i=0;$i<$size;$i++)
{
$content.='<tr '.($i%2==0?'BGCOLOR="#FFFFFF"':'').'><td><b>'.$status_list[$i]['text'].':</b></td>';
for($s=0;$s<$name_size;$s++)
$content.='<td align="center"><INPUT TYPE=RADIO NAME="'.$status_list[$i]['text'].'" ID="'.$status_list[$i]['id'].'"VALUE="'.$s.'"'.($status_list[$i]['state']==$s?' CHECKED':'').' onchange="UpdateStateList()"></td>';
$content.='</tr>';
}
$content.='</tbody></table></center></div>';
$content.=zen_draw_hidden_field('configuration_value',$value);
return $content;
}
function GetState($status_id)
{
$status_list=GetOrdersStatusList();
foreach($status_list as $status)
if($status['id']==$status_id)
return $status['state'];
}
function GetOrdersStatusList()
{
global $db;
$states=GetRewardPointStateList();
$list=array();
if(isset($_SESSION['languages_id']))
$sql="SELECT * FROM ".TABLE_ORDERS_STATUS." WHERE language_id='".$_SESSION['languages_id']."' ORDER BY orders_status_id;";
else
$sql="SELECT * FROM ".TABLE_ORDERS_STATUS." WHERE 1 ORDER BY orders_status_id;";
$result=$db->Execute($sql);
$i=0;
while(!$result->EOF)
{
$list[]=array('id'=>$result->fields['orders_status_id'],'text'=>$result->fields['orders_status_name'],'state'=>(isset($states[$result->fields['orders_status_id']])?$states[$result->fields['orders_status_id']]:STATUS_IGNORE));
$i++;
$result->MoveNext();
}
return $list;
}
function GetRewardPointStateList()
{
if(REWARD_POINTS_STATUS_TRACK=='')
return NULL;
else
{
$states=array();
$list=explode("/",REWARD_POINTS_STATUS_TRACK);
$pend_list=explode(",",$list[0]);
foreach($pend_list as $pend_item)
$states[$pend_item]=STATUS_PENDING;
$earn_list=explode(",",$list[1]);
foreach($earn_list as $earn_item)
$states[$earn_item]=STATUS_PROCESSED;
return $states;
}
}
function CheckText($string1,$string2='NULL')
{
return (is_null($string1)?$string2:$string1);
}
function GetPricingGroupList()
{
global $db;
$group_array_query = $db->execute("SELECT rm.scope_id, rm.redeem_ratio, gp.group_name FROM ".TABLE_REWARD_MASTER." rm, ".TABLE_GROUP_PRICING." gp WHERE rm.scope_id=gp.group_id AND rm.scope='".SCOPE_GROUP."';");
$group_array[]=array('id'=>0, 'text'=>TEXT_NONE);
while(!$group_array_query->EOF)
{
$group_array[]=array('id'=>$group_array_query->fields['scope_id'], 'text'=>$group_array_query->fields['group_name'].': '.$group_array_query->fields['redeem_ratio']);
$group_array_query->MoveNext();
}
return $group_array;
}
function UseRewardPointNewAccountAwardFunction($value)
{
if($value==0)
return TEXT_NO_NEW_ACCOUNT_AWARD;
else
if($value>0)
return abs((int)$value).TEXT_NEW_ACCOUNT_EARNED_AWARD;
else
return abs((int)$value).TEXT_NEW_ACCOUNT_PENDING_AWARD;
}
function SetRewardPointNewAccountAwardFunction($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 UseRewardPointDiscountTableFunction($value)
{
$discount_list=GetRewardPointDiscountTable();
$content='<div id="RewardPointDiscountTable" style="display: block"><center><table width="200px" border="0" cellspacing="0" bgcolor="#d0d0d0"><tbody align="right">';
$content.='<tr><th width="80px">Discount</th><th width="120px">Points Required</th></tr>';
$size=count($discount_list);
for($i=0;$i<$size;$i++)
$content.='<tr'.($i%2==0?' BGCOLOR="#FFFFFF"':'').'><td>'.$discount_list[$i]['discount'].'</td><td>'.$discount_list[$i]['required'].'</td></tr>';
//$content.=zen_draw_hidden_field('configuration_value',$value);
$content.='</tbody></table></center></div><br />';
return $content;
}
function GetRewardPointDiscountRow($reward_points)
{
$discount_list=GetRewardPointDiscountTable();
$size=count($discount_list);
for($i=0;$i<$size;$i++)
if($reward_points<$discount_list[$i]['required'])
if($i>0)
return $discount_list[$i-1];
else
return NULL;
return $discount_list[$size-1];
}
function GetRewardPointDiscountTable()
{
if(MODULE_ORDER_TOTAL_REWARD_POINTS_DISCOUNT_TABLE=='')
return NULL;
else
{
$discounts=array();
$list=explode(",",MODULE_ORDER_TOTAL_REWARD_POINTS_DISCOUNT_TABLE);
foreach($list as $record)
{
$fields=explode(":",$record);
array_push($discounts,array('discount'=>$fields[0],'required'=>$fields[1]));
}
usort($discounts,"SortDiscountTable");
return $discounts;
}
}
function SortDiscountTable($a,$b)
{
$diff=(int)$a['discount']-(int)$b['discount'];
return ($diff==0?0:$diff>0?1:-1);
}
function SetRewardPointDiscountTableFunction($value,$key='')
{
require('includes/javascript/reward_points.js');
$discount_list=GetRewardPointDiscountTable();
$content='<div id="RewardPointDiscountTableDiv" style="display: block"><center><table id="RewardPointDiscountTable" width="220px" border="0" cellspacing="0" bgcolor="#d0d0d0"><tbody align="right">';
$content.='<tr><th width="80px">Discount</th><th width="120px">Points Required</th><th width="20px"> </th></tr>';
$size=count($discount_list);
for($i=0;$i<$size;$i++)
$content.='<tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="SetDiscountTableFields(this)"><td>'.$discount_list[$i]['discount'].'</td><td>'.$discount_list[$i]['required'].'</td><td>'.zen_image(DIR_WS_IMAGES . 'icon_rp_delete.gif', ICON_DELETE,'','','onclick="DeleteDiscountRecord(this)"').'</tr>';
$content.='<tr><td>'.zen_draw_input_field('discountField','','size="8" maxlength="8" id="discountField"').'</td><td>'.zen_draw_input_field('requiredField','','size="8" maxlength="8" id="requiredField"').'</td><td>'.zen_image(DIR_WS_IMAGES . 'icon_rp_add.gif', ICON_ADD_CONFIRM,'','','onclick="AddOrUpdateDiscountRecord()"').'</td></tr>';
$content.='</tbody></table></center></div><br />';
$content.=zen_draw_hidden_field('configuration[MODULE_ORDER_TOTAL_REWARD_POINTS_DISCOUNT_TABLE]',$value);
return $content;
}
function UseRewardPointDiscountTypeFunction($value)
{
if($value=='0')
$content=MODULE_ORDER_TOTAL_REWARD_POINTS_DISCOUNT_TYPE_0;
else
$content=MODULE_ORDER_TOTAL_REWARD_POINTS_DISCOUNT_TYPE_1;
return $content;
}
//--- Advanced calculate functions
function UseRewardPointAdvancedCalculateTableFunction($value)
{
if($value=='')
$content=ADVANCED_RULES_DISABLED;
else
$content=ADVANCED_RULES_ENABLED;
return $content;
/*
$module_list=GetRewardPointAdvancedCalculateTable();
$content='<div id="RewardPointAdvancedCalculateTable" style="display: block"><center><table width="200px" border="0" cellspacing="0" bgcolor="#d0d0d0"><tbody align="left">';
$content.='<tr><th width="140px">Module</th><th width="60px">Action</th></tr>';
$size=count($module_list);
for($i=0;$i<$size;$i++)
$content.='<tr'.($i%2==0?' BGCOLOR="#FFFFFF"':'').'><td>'.$module_list[$i]['module'].'</td><td>'.$module_list[$i]['action'].'</td></tr>';
//$content.=zen_draw_hidden_field('configuration_value',$value);
$content.='</tbody></table></center></div><br />';
return $content;
*/
}
function GetRewardPointAdvancedCalculateTable()
{
if(REWARD_POINTS_ADVANCED_CALCULATE_TABLE=='')
return NULL;
else
{
$modules=array();
$list=explode(",",REWARD_POINTS_ADVANCED_CALCULATE_TABLE);
foreach($list as $record)
array_push($modules,array('module'=>substr($record,1),'action'=>(substr($record,0,1)=="-"?"Subtract":"Add")));
//usort($modules,"SortModulesTable");
return $modules;
}
}
function SortModulesTable($a,$b)
{
$diff=(int)$a['discount']-(int)$b['discount'];
return ($diff==0?0:$diff>0?1:-1);
}
function SetRewardPointAdvancedCalculateTableFunction($value,$key='')
{
require('includes/javascript/reward_points.js');
$ignore_list=array("ot_subtotal","ot_reward_points","ot_reward_points_debug","ot_reward_points_display","ot_reward_points_discount","ot_reward_points_redeem","ot_total");
$action_list=array(array('id'=>"Subtract",'text'=>"Subtract"),array('id'=>"Add",'text'=>"Add"));
$module_list=GetRewardPointAdvancedCalculateTable();
$installed_module_list=array();
$module_directory=GetInstalledModules(DIR_FS_CATALOG_MODULES.'order_total/');
foreach($module_directory as $value)
if(($module=substr($value,0,strrpos($value, '.')))!=NULL)
if(!in_array($module,$ignore_list))
array_push($installed_module_list,array('id'=>$module,'text'=>$module));
sort($installed_module_list);
$content='<div id="RewardPointAdvancedCalculateTableDiv" style="display: block"><center><table id="RewardPointAdvancedCalculateTable" width="220px" border="0" cellspacing="0" bgcolor="#d0d0d0"><tbody align="left">';
$content.='<tr><th width="140px">Module</th><th width="60px">Action</th><th width="20px"> </th></tr>';
$size=count($module_list);
for($i=0;$i<$size;$i++)
$content.='<tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"><td>'.$module_list[$i]['module'].'</td><td>'.$module_list[$i]['action'].'</td><td>'.zen_image(DIR_WS_IMAGES . 'icon_rp_delete.gif', ICON_DELETE,'','','onclick="DeleteAdvancedCalculateRecord(this)"').'</tr>';
$content.='<tr><td>'.zen_draw_pull_down_menu('moduleField',$installed_module_list,'size="16" maxlength="16" id="moduleField"').'</td><td>'.zen_draw_pull_down_menu('actionField',$action_list,'size="8" maxlength="8" id="actionField"').'</td><td>'.zen_image(DIR_WS_IMAGES . 'icon_rp_add.gif', ICON_ADD_CONFIRM,'','','onclick="AddAdvancedCalculateRecord()"').'</td></tr>';
$content.='</tbody></table></center></div><br />';
$content.=zen_draw_hidden_field('configuration_value',$value);
return $content;
}
part 2
Sorry I had to break it up but the forum will only allow so many characters per post.Code:function GetInstalledModules($module_directory)
{
$directory_array=array();
if($dir=@dir($module_directory))
while($file=$dir->read())
if(!is_dir($module_directory.$file))
if(substr($file,strrpos($file,'.'))==".php")
$directory_array[]=$file;
sort($directory_array);
$dir->close();
return $directory_array;
}
/*
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;
}
*/
?>
The error message states: "undefined function getrewardpoints()". Line 40 in "ot_reward_points_display.php" (downloaded from the Reward Point Full Suite 2.1b) does not call getrewardpoints() it calls GetRewardPoints(). Note the upper / lower case letters?
Not sure how your install ended up with different names in the files (one with uppercase one with lowercase)... But case does matter. I'd suggest downloading a clean copy of this module and re-installing (one step at a time).
Okay. Thank you. Not sure either as I just searched my download for the text getrewardpoints and everyone of the comes back with GetRewardPoints But as you recommend I will delete all these files and download a fresh version and reinstall.
Thank you very much for your help Ihungil!
Last night I deleted everyfile in the reward_point_full_suite_2.1b folder from my site. I did not do the database uninstall since I have a ton of people with points already and don't want to loose them. Then I reinstalled. Now my error is:
I cannot find this file in the install folder anywhere. Can someone please tell me how to adjust this file?Code:[01-Feb-2014 01:15:50] PHP Fatal error: Class 'RewardPoints' not found in /home4/w57dsjmm/public_html/d132s/includes/autoload_func.php on line 79
Thank you
The following file is located there.
Attachment 13736Code:<?php
/**
* Observer class used to handle reward points in an order
*
*/
class RewardPoints extends base
{
function RewardPoints()
{
global $zco_notifier;
$zco_notifier->attach($this, array('NOTIFY_ORDER_DURING_CREATE_ADDED_ORDER_HEADER','NOTIFY_MODULE_CREATE_ACCOUNT_ADDED_CUSTOMER_RECORD','NOTIFY_LOGIN_SUCCESS'));
}
function update(&$class, $eventID, $paramsArray)
{
if(isset($_SESSION['customer_id']))
$customer_id=(int)$_SESSION['customer_id'];
else
if(isset($paramsArray['customer_id']))
$customer_id=(int)$paramsArray['customer_id'];
else
error_log("Customer ID not passed to Reward Point observer. EventID=".$eventID."\r\n");
//error_log("Customer ID=".$customer_id.". EventID=".$eventID.". Reward Points=".REWARD_POINTS_NEW_ACCOUNT_REWARD."\r\n");
switch($eventID)
{
//case NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL:
//case NOTIFY_CHECKOUT_PROCESS_BEGIN:
//case NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE_ADD_PRODUCTS:
//case NOTIFY_ORDER_AFTER_ORDER_CREATE_ADD_PRODUCTS:
case NOTIFY_ORDER_DURING_CREATE_ADDED_ORDER_HEADER:
$this->StoreRewardPoints($customer_id);
break;
case NOTIFY_MODULE_CREATE_ACCOUNT_ADDED_CUSTOMER_RECORD:
if(REWARD_POINTS_NEW_ACCOUNT_REWARD!=0)
if(REWARD_POINTS_NEW_ACCOUNT_REWARD>0 && !HasRewardPoints($customer_id))
$this->AddRewardPoints($customer_id,REWARD_POINTS_NEW_ACCOUNT_REWARD);
else
if(REWARD_POINTS_NEW_ACCOUNT_REWARD<0 && !HasPendingPoints($customer_id))
$this->AddPendingPoints($customer_id,abs(REWARD_POINTS_NEW_ACCOUNT_REWARD));
case NOTIFY_LOGIN_SUCCESS:
if(isset($customer_id) && REWARD_POINTS_SUNRISE_PERIOD>0)
$this->UpdateRewardStatus($customer_id);
break;
}
}
function after_checkout($customer_id)
{
StoreRewardPoints($customer_id);
}
function AddRewardPoints($customer_id,$reward_points)
{
UpdateCustomerRewardPoints($customer_id,$reward_points,0);
}
function AddPendingPoints($customer_id,$pending_points)
{
UpdateCustomerRewardPoints($customer_id,0,$pending_points);
}
function StoreRewardPoints($customer_id)
{
global $db,$order;
//$reward_points=GetRewardPoints($order->products);
if(isset($_SESSION['REWARD_POINTS_EARNED']))
{
$reward_points=(int)$_SESSION['REWARD_POINTS_EARNED'];
unset($_SESSION['REWARD_POINTS_EARNED']);
// foreach($order->products as $product)
// $reward_points+=GetRewardPoints($product['id'],$product['attributes'])*$product['qty'];
if(isset($_SESSION['redeemed_value']))
{
$reward_ratio=GetGlobalRewardPointRatio();
$reward_points=$reward_points-($reward_ratio*$_SESSION['redeemed_value']);
unset($_SESSION['redeemed_value']);
}
$reward_points=zen_round($reward_points,0);
if($reward_points>0)
{
if(REWARD_POINTS_ALLOW_TOTAL=='0')
$status=($order->info['subtotal']>0?STATUS_PENDING:STATUS_PROCESSED);
else
$status=($order->info['total']>0?STATUS_PENDING:STATUS_PROCESSED);
if($status==STATUS_PENDING) // Place reward points into pending if awaiting payment/status change
$sql="INSERT INTO ".TABLE_REWARD_CUSTOMER_POINTS." SET customers_id='".$customer_id."', pending_points='".$reward_points."' ON DUPLICATE KEY UPDATE pending_points=pending_points+".$reward_points.";";
else // Reward points and or coupons have covered the price of the purchase- place into processed
$sql="INSERT INTO ".TABLE_REWARD_CUSTOMER_POINTS." SET customers_id='".$customer_id."', reward_points='".$reward_points."' ON DUPLICATE KEY UPDATE reward_points=reward_points+".$reward_points.";";
$db->Execute($sql);
$sql="REPLACE INTO ".TABLE_REWARD_STATUS_TRACK." SET customers_id='".$customer_id."', orders_id='".GetCustomersLastOrderID($customer_id)."', date=NOW(), reward_points='".$reward_points."', status=".$status.";";
$db->Execute($sql);
}
}
else
error_log("StoreRewardPoints called but SESSION['REWARD_POINTS_EARNED'] not found");
// RefreshCustomerPointTable((int)$_SESSION['customer_id']);
}
function UpdateRewardStatus($customer_id)
{
global $db;
if(($result=$db->Execute("SELECT SUM(reward_points) FROM ".TABLE_REWARD_STATUS_TRACK." WHERE customers_id=".$customer_id." AND status=".STATUS_PENDING." AND date<NOW()-INTERVAL ".REWARD_POINTS_SUNRISE_PERIOD." DAY;")))
{
$db->Execute("UPDATE ".TABLE_REWARD_STATUS_TRACK." SET status=".STATUS_PROCESSED." WHERE customers_id=".$customer_id." AND status=".STATUS_PENDING." AND date<NOW()-INTERVAL ".REWARD_POINTS_SUNRISE_PERIOD." DAY;");
if($points=$result->fields['SUM(reward_points)'])
UpdateCustomerRewardPoints($customer_id,$points,-$points);
}
}
}
function HasRewardPoints($customer_id)
{
return (GetCustomersRewardPoints($customer_id)!=0);
}
function HasPendingPoints($customer_id)
{
return (GetCustomersPendingPoints($customer_id)!=0);
}
?>
If i try install for 1.3.9h have problem ? It's work well ?
I would double check all the paths in both "configure.php" files... If these are off in any way, Zen Cart will report errors loading files during the auto_load sequence...
If you are using a web based "file manager" to upload files, I would trying to upload using FTP software on your computer (and making sure it sends php and other text files as type TEXT). Doing so ensures line endings are converted (apple, windows, and unix use different line endings)... Probably not the problem, but just something one can also check...
where the code for reward points ? in the tpl_product_info_display.php ver 1.3.9 ? need merge with my tpl_product_info_display.php
I've been using this for about 2 years now and it works great!
Is there any way to have it configured so that if a product is on sale, the customer can't redeem their points on that product? How about if the customer has 5 products in their cart and one of them is on sale and the other 4 aren't, can the redeem be calculated on the 4 that aren't on sale and ignore the one that's on sale?
No the reward points system will not do what you are asking. It will require rewriting the code. You will have to hire someone to get those extra features.
It was never added or updated in zen cart 1.3.9. Look at the tpl_product_info_display.php in zen_1.5.0 and copy this block of code and put it where you want it to show.
PHP Code:
<!--bof Product Reward Points block -->
<h2 id="productRewardPoints" class="productRewardPoints">
<?php
/**
* display the product reward points
*/
include($template->get_template_dir('/tpl_product_reward_points.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_product_reward_points.php');
?>
</h2>
<!--eof Product Reward Points block -->
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-??
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...
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.PHP Code:
$special_price=zen_get_products_special_price($products_id);
if(REWARD_POINTS_SPECIAL_ADJUST=='1' && $special_price )
$reward_price=$special_price;
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.
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.
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.
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?
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?
Code: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;");
}
Hi,
in my site, when i change attributes the points dont change, please take a look: 66.147.242.164/~kiteaddi
can share products ( facebook, twiiter ) and get points ?
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?
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:
and adding "p.products_tax_class_id" field in the select query...PHP Code:
//DFK - add taxes to reward_price
$taxrate = zen_get_tax_rate($result->fields['products_tax_class_id']);
$reward_price+= $reward_price*$taxrate/100;
there's any cleaner way to fix this?
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")
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:
Then letting the system allocate them overnight.Code:update reward_customer_points
set pending_points = 10000
where products_id = 3
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.
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.
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:
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?Code: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 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".
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!
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
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.
Code: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;