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

Reward Points Module for ZC v13x

Locked

Views: 472,224

Results 2,341 to 2,360 of 2,476
This thread is locked. New replies are disabled.
19 Nov 2013, 6:35 PM
#2341
izar74 avatar

izar74

Zen Follower

Join Date:
Mar 2009
Location:
Italy
Posts:
155
Plugin Contributions:
0

Reward Points Module for ZC v13x

prettyeyes1:

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.

Can You please tell which are your settings under Configuration/Reward Points?

Have you checked if that client have pending points (from client/reward Points menu)?

From what You wrote It seems that only few point are passed from "pending" to "earned".

19 Nov 2013, 7:12 PM
#2342
prettyeyes1 avatar

prettyeyes1

New Zenner

Join Date:
Mar 2010
Posts:
19
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

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.

19 Nov 2013, 10:38 PM
#2343
countrycharm avatar

countrycharm

Totally Zenned

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

Re: Reward Points Module for ZC v13x

lhungil:

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.

Thank you for sharing some of your thoughts they are well appreciated for sure. If you ever get some extra time feel fee to do some more poking.

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

19 Nov 2013, 10:40 PM
#2344
izar74 avatar

izar74

Zen Follower

Join Date:
Mar 2009
Location:
Italy
Posts:
155
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

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

19 Nov 2013, 10:43 PM
#2345
izar74 avatar

izar74

Zen Follower

Join Date:
Mar 2009
Location:
Italy
Posts:
155
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

lhungil:

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.

Thanks so muck for the information, as already said feel free to poke, It's always a pleasure when people share knowledge ;-)

19 Nov 2013, 10:48 PM
#2346
countrycharm avatar

countrycharm

Totally Zenned

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

Re: Reward Points Module for ZC v13x

izar74:

Thanks so muck for the information, as already said feel free to poke, It's always a pleasure when people share knowledge ;-)

Don't think your not appreciated you are. It's Always good to have 2 or 3 heads working in the same thread to accomplish new and improved things.

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

19 Nov 2013, 11:40 PM
#2347
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

countrycharm:

Thank you for sharing some of your thoughts they are well appreciated for sure. If you ever get some extra time feel fee to do some more poking.

I'm sure lhungil will if and when one of his clients requires Rewards Points..:laugh: Personally all of my contributions are linked to something I've done for a client versus the "just for the heck of it" kinds of contributions..

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.

20 Nov 2013, 9:27 AM
#2348
izar74 avatar

izar74

Zen Follower

Join Date:
Mar 2009
Location:
Italy
Posts:
155
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

DivaVocals:

I'm sure lhungil will if and when one of his clients requires Rewards Points..:laugh: Personally all of my contributions are linked to something I've done for a client versus the "just for the heck of it" kinds of contributions..

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

26 Nov 2013, 3:50 PM
#2349
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

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.

26 Nov 2013, 4:20 PM
#2350
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

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

30 Nov 2013, 5:34 PM
#2351
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

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

3 Dec 2013, 1:09 PM
#2352
hubert avatar

hubert

Zen Follower

Join Date:
Mar 2005
Posts:
229
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

izar74:

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:

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;

}

> 
> It should work now :smile:

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
```php
<?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);
        }

must be enough.

Thanks for reading

4 Dec 2013, 12:50 AM
#2353
hubert avatar

hubert

Zen Follower

Join Date:
Mar 2005
Posts:
229
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

...Oops I just missed two functions

        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;
}   

But I'm still wondering if an include or an include_once would work and would not be more elegant ?

Hubert

12 Dec 2013, 1:53 AM
#2354
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

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

13 Dec 2013, 3:49 PM
#2355
candleman avatar

candleman

Zen Follower

Join Date:
May 2008
Posts:
183
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

countrycharm:

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.

I have done this and it still doesnt work.
I wonder if it is something to do with the Nochex callback?
Paypal works no problem and Nochex paid orders show the points on the invoice.

Im using version 1.5.1, database patch 1.5.1, PHP Version 5.3.27

https://www.candlewithcare.co.uk
Luxury Scented
Candles at great prices!

18 Dec 2013, 8:38 PM
#2356
geeker avatar

geeker

New Zenner

Join Date:
Mar 2011
Posts:
52
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

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.

23 Dec 2013, 7:00 PM
#2357
southshorepizza avatar

southshorepizza

Zen Follower

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

Re: Reward Points Module for ZC v13x

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

27 Dec 2013, 2:43 AM
#2358
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:

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:

SELECT rewards_id, orders_id, date, reward_points, status FROM  zen_reward_status_track WHERE[B] customers_id= [/B]AND status=0 ORDER BY date  DESC LIMIT 12;

Hopefully someone knows where/how to correct the errant SQL query..

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.

22 Jan 2014, 1:42 PM
#2359
annabelleswigs avatar

annabelleswigs

New Zenner

Join Date:
Jun 2010
Posts:
3
Plugin Contributions:
0

Re: Reward Points Module for ZC v13x

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.

22 Jan 2014, 3:25 PM
#2360
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

hubert:

... 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 ?
    ...
    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.

hubert:

...
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. :-)

  1. 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;
    ...
    There are at least three approaches to solving this issue which avoid duplicate code (pick one):
  1. Create an auto_load file on the admin which loads the functions file from the catalog.
  2. Move all functions required by the order total class - inside the order total class.
  3. In the order total class do a check (IS_ADMIN / function_exists). If needed use include_once to load the functions file.

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