Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

### POINTS AND REWARDS MODULE V1.00 ###


Recommended Posts

Right - i've found the cause of the problems:

 

A) Missing Functions Problem:

The included file in catalog/includes/functions/redemptions.php is missing the necessary functions - if u replace it with the one from the full install dload from http://www.deep-silver.com/oscommerce/poin...eward_v1.00.zip then it will fix the missing functions problem.

 

B) Parse error problem with checkout_confirmation.php:

This is caused by leaving in a line that shouldnt be left in, that is overlooked in the install instructions...

When you make the second edit in checkout_confirmation.php, the instructions should read:

 

Find this.... (start at aprox. line no.55)

 

  if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) { 

 

  tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));

  }

 

..and replace it with this.......

 

##### Points/Rewards  Module v1.00 check for error BOF #######

//force customers to select other payment method if the points total not enogh to cover the cost.

// if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {

  if ( (is_array($payment_modules->modules)) && (sizeof($payment_modules->modules) > 1) && (!is_object($$payment)) && ($customer_shopping_points_spending * REDEEM_POINT_VALUE < $order->info['total'] ) || (is_object($$payment) && ($$payment->enabled == false)) ) {

    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));

  }

// customer can't use points over the order total       

  if ($customer_shopping_points_spending * REDEEM_POINT_VALUE > $order->info['total']) {

      $customer_shopping_points_spending = 0;

    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(REDEEM_SYSTEM_ERROR_POINTS_OVER), 'SSL'));

  }

########  Points/Rewards  Module v1.00 EOF #################*/

 

Note the bolded line, which is actually commented out in the copy section...

 

So, for anybody who's already got this contrib installed, but not working, search for

if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {

and remove the first instance of it...

 

I'm going to add these changes to the files and instructions and upload it so that we've got a working copy uploaded.

 

Hope this solves the problems that most of u r getting.

 

Cheers

Fatmcgav

Link to comment
Share on other sites

POINTS AND REWARDS MODULE v1.2 - WORKING has now been uploaded, this is simply a fixed version including the correct redemptions.php file and a slight edit to the install instructions to fix the parse error experienced with checkout_confirmation.php

 

HTH

 

Cheers

Fatmcgav

Link to comment
Share on other sites

Error when I open my_points.php

Warning: Missing argument 1 for tep_get_shopping_points() in /usr/local/apache/htdocs/evabijoux/includes/functions/redemptions.php on line 17

 

Fatal error: Call to undefined function: tep_count_pending_rows() in /usr/local/apache/htdocs/evabijoux/my_points.php on line 72

 

 

Still getting this error with the 1.2 update. Followed instructions and downloaded the redemptions.php file and copied over. nothing. :(

Link to comment
Share on other sites

POINTS AND REWARDS MODULE v1.2 - WORKING has now been uploaded, this is simply a fixed version including the correct redemptions.php file and a slight edit to the install instructions to fix the parse error experienced with checkout_confirmation.php

 

HTH

 

Cheers

Fatmcgav

 

someone has tested it?

is it working ?

:-"

 

i dont want to broke my shop again ...

and thx to fatmcgav for the efforts and for the currency "change" ;)

 

 

Also, i notice that in the readme file there is a little mistake.

-- Files to Modify in catalog section --------------

 

catalog/account.php

catalog/checkout_confirmation.php

catalog/checkout_payment.php

catalog/checkout_process.php

catalog/create_account.php

catalog/create_account_success.php

catalog/logoff.php

catalog/includes/application_top.php

catalog/includes/database_tables.php

catalog/includes/filenames.php

catalog/includes/boxes/information.php

catalog/includes/languages/english.php

catalog/includes/languages/english/account.php

catalog/includes/languages/english/checkout_payment.php

catalog/includes/languages/english/create_account_success.php

 

********* Edit files in catalog section ***************

 

Logoff.php isnt modified...

Link to comment
Share on other sites

It works completely. I did several test purchases. The only error I get is:

 

Error when I open my_points.php

Warning: Missing argument 1 for tep_get_shopping_points() in /usr/local/apache/htdocs/evabijoux/includes/functions/redemptions.php on line 17

 

Fatal error: Call to undefined function: tep_count_pending_rows() in /usr/local/apache/htdocs/evabijoux/my_points.php on line 72

 

and that's when you are the customer trying to view how many points you have earned under my account.

Link to comment
Share on other sites

It works completely.  I did several test purchases.  The only error I get is:

 

Error when I open my_points.php

Warning: Missing argument 1 for tep_get_shopping_points() in /usr/local/apache/htdocs/evabijoux/includes/functions/redemptions.php on line 17

 

Fatal error: Call to undefined function: tep_count_pending_rows() in /usr/local/apache/htdocs/evabijoux/my_points.php on line 72

 

and that's when you are the customer trying to view how many points you have earned under my account.

Hmm, u got a pm about this un :D

Link to comment
Share on other sites

hello,

 

i have the same problem:

 

Error when I open my_points.php

Warning: Missing argument 1 for tep_get_shopping_points() in /usr/local/apache/htdocs/evabijoux/includes/functions/redemptions.php on line 17

 

Fatal error: Call to undefined function: tep_count_pending_rows() in /usr/local/apache/htdocs/evabijoux/my_points.php on line 72

 

 

regards

rainer

 

 

PHP Version: 4.3.11

MySQL 4.0.24

Link to comment
Share on other sites

Woopsie, looks like i put the wrong redemptions.php file in :blush: :blush: :'(

 

The correct code is:

<?php
/*
 $Id: redemptions.php, v 1.10 2005/05/21 10:11:22 dgw_ Exp $
 http://www.deep-silver.com

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2005 osCommerce

 Released under the GNU General Public License
*/


// fetches the shopping points the customer currently has
 function tep_get_shopping_points($id = '', $check_session = true) {
   global $customer_id;

   if (is_numeric($id) == false) {
     if (tep_session_is_registered('customer_id')) {
       $id = $customer_id;
     } else {
       return 0;
     }
   }

   if ($check_session == true) {
     if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) {
       return 0;
     }
   }

$points_query = tep_db_query("select customers_shopping_points from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$id . "'");
   $points = tep_db_fetch_array($points_query);

   return $points['customers_shopping_points'];
 }

 
// sets the shopping points the customer currently has
 function tep_set_shopping_points($points, $customer_id) {
  
tep_db_query("update " . TABLE_CUSTOMERS . " set customers_shopping_points = '" . (int)$points . "' where customers_id = '" . (int)$customer_id . "'");
 }

 function tep_calc_shopping_pvalue($points) {
  
return((float)$points * (float)REDEEM_POINT_VALUE);
 }

// fetches the pending rows the customer currently has
 function tep_count_pending_rows($id = '', $check_session = true) {
   global $customer_id;

   if (is_numeric($id) == false) {
     if (tep_session_is_registered('customer_id')) {
       $id = $customer_id;
     } else {
       return 0;
     }
   }

   if ($check_session == true) {
     if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) {
       return 0;
     }
   }

   $rows_check_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS_POINTS_PENDING . " where customer_id = '" . (int)$id . "'");
   $rows_check = tep_db_fetch_array($rows_check_query);

   return $rows_check['total'];
 }
   
// fetches the products restriction if enabled.
   function get_points_redemption_rules($customer_id, $order) {
     
    if (REDEMPTION_RESTRICTION == 'true') {  
     
     for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
 if (!(substr($order->products[$i]['model'], 0, 10) == RESTRICTION_MODEL)) {
	 return false;
 }
  }

       return true;
       
     } else {
       return false;
     }
   }

// this function sets the customers Pending points
 function tep_add_pending_points($ordernum, $customer_id, $insert_id,$points_toadd) {

   $points_awarded = $points_toadd * POINTS_PER_AMOUNT_PURCHASE;
     
   $sql_data_array = array('unique_id' => '',
                           'customer_id' => $customer_id,
                           'orders_id' => $insert_id,
                           'points_pending' => $points_awarded,
                           'date_added' => 'now()', 
                           'comment' => 'TEXT_DEFAULT_COMMENT', 
                           'status' => 1);
                           
   tep_db_perform(TABLE_CUSTOMERS_POINTS_PENDING, $sql_data_array);
 }


// this function sets the new signup customers welcome points
 function tep_add_welcome_points($customer_id) {

   $welcome_points = NEW_SIGNUP_POINT_AMOUNT;
     
tep_db_query('update '. TABLE_CUSTOMERS . ' set customers_shopping_points = customers_shopping_points + '. $welcome_points . ' where customers_id = '. (int)$customer_id);          
 }

?>

 

Appologies again, and i'll get the correct one uploaded now...

 

Cheers

Fatmcgav

Link to comment
Share on other sites

Does anyone have the Credit Class Contributuion installed with this?

 

I've got points being added and showing up in the account ok.

 

I can't redeem them though. There is no box on the checkout_payment.php page.

Link to comment
Share on other sites

Also, i notice that in the readme file there is a little mistake.

-- Files to Modify in catalog section --------------

 

    catalog/account.php

    catalog/checkout_confirmation.php

    catalog/checkout_payment.php

    catalog/checkout_process.php

    catalog/create_account.php

    catalog/create_account_success.php

    catalog/logoff.php

    catalog/includes/application_top.php

    catalog/includes/database_tables.php

    catalog/includes/filenames.php

    catalog/includes/boxes/information.php

    catalog/includes/languages/english.php

    catalog/includes/languages/english/account.php

    catalog/includes/languages/english/checkout_payment.php

    catalog/includes/languages/english/create_account_success.php

   

********* Edit files in  catalog section ***************

 

Logoff.php isnt modified...

 

 

In the install instructions, this bit:

 

G. open catalog/checkout_process.php

Clear sessions used at checkout if by any chance they still active.

 

Find... (aprox. line 275)

 

tep_session_unregister('comments');

 

... and add after.....

 

tep_session_unregister('customer_shopping_points');// Points/Rewards Module v1.00

tep_session_unregister('customer_shopping_points_spending');// Points/Rewards Module v1.00

 

should refer to logoff.php

Link to comment
Share on other sites

Does anyone have the Credit Class Contributuion installed with this?

 

I've got points being added and showing up in the account ok.

 

I can't redeem them though. There is no box on the checkout_payment.php page.

 

 

I'm being stupid >_< I had a minimum redemption figure set which is why it didn't show up.

 

 

Tamsyn

Link to comment
Share on other sites

In the install instructions, this bit:

 

G.  open catalog/checkout_process.php

Clear sessions used at checkout if by any chance they still active.

 

Find... (aprox. line 275)

 

  tep_session_unregister('comments');

 

... and add after.....

 

  tep_session_unregister('customer_shopping_points');// Points/Rewards  Module v1.00

  tep_session_unregister('customer_shopping_points_spending');// Points/Rewards  Module v1.00

 

should refer to logoff.php

That makes sense - i did wonderwhy it said to modify the same file with the same information twice :blink: <_< :huh:

Link to comment
Share on other sites

To all of you out there.

It's good to know that you can run this mod on your site and thank god that all the

post here regard the YEN or $ got clear and more then all the problem with missing fuction that some people where having errors.

well to be hunest I really don't find any diff in the catalog/includes/functions/redemptions.php that i have in my site and the one that had been fixed if you compers the files you will see that its the same file.

the most recent updated or latest or call it what ever you want but its still Points/Rewards Module v1.00 since nothing changed in the files and WORKING vesrsion was up and running way before who ever made it to v.100

and the screenshots and live test can confirm that, for me its still Points/Rewards Module v1.00 and its still consider beta and subject to bugs or error. even if its looks like it run well you must remember that i just made it and it take time before

other users try it enough to find bugs.

BUT its really dosent metter you can call it Points/Rewards Module v1.00 or Points/Rewards Module v1.2 its up to you as long as you happy it with then im happy to .that is the reson i made it from the first place.

God bless all of us.

DEEP SILVER ACCESSORY

p.s please don't mine my spelling mistakes :lol:

Remember - - - "STRESSED" spelled backwards "DESSERTS"

Link to comment
Share on other sites

Thats cool dude :D

 

The problems were caused by the redemptions.php file in the original zip file missing some code - this was fixed evetually by the last upload :D

The parse error was due to a missed line in the installation file, but this was also corrected with the 1.2 upload.

 

Just making sure it works for everybody out of the box.

 

Still a great contrib though dude :D

 

To all of you out there.

It's good to know that you can run this mod on your site and thank god that all the

post here regard the YEN or $ got clear and more then all the problem with missing fuction that some people where having errors.

well to be hunest I really don't find any diff in the catalog/includes/functions/redemptions.php that i have in my site and the one that had been fixed if you compers the files you will see that its the same file.

the most recent updated or latest or call it what ever you want but its still Points/Rewards Module v1.00 since nothing changed in the files and WORKING vesrsion was up and running way before who ever made it to v.100

and the screenshots and live test can confirm that, for me its still Points/Rewards Module v1.00 and its still consider beta and subject to bugs or error. even if its looks like it run well you must remember that i just made it and it take time before

other users try it enough to find bugs.

BUT its really dosent metter you can call it Points/Rewards Module v1.00 or Points/Rewards Module v1.2 its up to you as long as you happy it with then im happy to .that is the reson i made it from the first place.

God bless all of us.

DEEP SILVER ACCESSORY

p.s please don't mine my spelling mistakes :lol:

Link to comment
Share on other sites

Thats cool dude :D

 

The problems were caused by the redemptions.php file in the original zip file missing some code - this was fixed evetually by the last upload :D

The parse error was due to a missed line in the installation file, but this was also corrected with the 1.2 upload.

 

Just making sure it works for everybody out of the box.

 

Still a great contrib though dude :D

Well.....

What ever as long as you happy with my contribution thats fine but please DO NOT uploads to the contribution page a zip that NOTcontain all of this package.(and write that it is).

Some people need screenshots and modified oscommerce files so they can get more idea of this and to be able to compair with the files they have.

If you really want put the whole packge at your site, setup a test shop and then give them a link to the where they can get this packge.

 

P.S

I'm not american and dude say nothing to me(Ihope that its not as bad as it sound :)

DEEP SILVER ACCESSORY

Remember - - - "STRESSED" spelled backwards "DESSERTS"

Link to comment
Share on other sites

Well.....

What ever as long as you happy with my contribution thats fine but please DO NOT uploads to the contribution page a zip that NOTcontain all of this package.(and write that it is).

Some people need screenshots and modified oscommerce files so they can get more idea of this and to be able to compair with the files they have.

If you really want put the whole packge at your site, setup a test shop and then give them a link to the where they can get this packge.

 

P.S

I'm not american and dude say nothing to me(Ihope that its not as bad as it sound :)

DEEP SILVER ACCESSORY

And in reply to ure above post and pm:

 

-----------------------------------------------------------------------------------------

Chill dude :D :D

 

The uploaded file contains the same files as the original download, apart from the changed redemptions.php and install - the original dload didnt contain the screenshots either - not the contrib install one anyway - the full one off ure site did, but not the one on the OSCom Site - all that contained was the install instructions, the new files and the sql.

 

Even the latest one u've uploaded doesnt contain the screenshots...

So the file I uploaded WAS complete in as much as it contained the sames files as i dloaded - nuthin more, nuthin less.

So i think U need to upload the complete file before U have a go at ME.

Also, for ure information, the latest one u uploaded contains the version of redemption.php which is missing code - if u dont believe me, i just dloaded and tested it, and it caused exactly the same error as before - try it for ureself if u dont believe me.

I'm glad u've taken account of the install file mods though ;)

 

Cheers again dude, and I hope u see what i've been saying all along that the wrong file redemptions.php is in the zip u uploaded.

 

Peace out dude. :thumbsup:

 

Fatmcgav

 

BTW: I'm not American either :)

And i dont like being told i'm wrong when i'm not <_< >_<

Edited by fatmcgav
Link to comment
Share on other sites

Are you happy with the change in your DB??

as you advised users to use your cod....

===================================================

UPDATE `configuration` SET `configuration_title` = 'Points per ?1 purchase',

`use_function` = NULL ,

`set_function` = NULL WHERE configuration_id` =191 LIMIT 1;

 

UPDATE `configuration` SET `configuration_title` = '? Redeem per point',

`use_function` = NULL ,

`set_function` = NULL WHERE `configuration_id` =192 LIMIT 1;

===================================================

 

what makes you so sure that other users configuration_id value match your value configuration_id` =191 ??????.

and im really wondering, applying this change made any diff in the way this module deals with the values for corrency????

It shows YEN but cosider it $, EURO, YEN POND RUPPIES, PESSOS, or whatever currency you want it will always used the default currency defined by admin.

But go ahead and change it if its make you sleep better. :thumbsup:

Remember - - - "STRESSED" spelled backwards "DESSERTS"

Link to comment
Share on other sites

WTF, where did that come from - that's on a totally unrelated line... I only quoted that code as a user asked for it, and yes, it's possible the config_id might be different, but the user in question replied and said that it worked fine... and if it didnt, i appologies, but i also included instructions on how to change it.

 

Anyhow, i dont see the point in this slaggin match - the only reason i responded in the first place is that u were'nt aware that the redemptions.php file in ure uploaded zip was broken... which I now see u have noticed and corrected.

I see no point in trying to 'score points' off each other, so lets just leave it at this...

 

And YES, for ure information, I am happy with the changes I made to MY DB!!!

 

Are you happy with the change in your DB??

as you advised users to use your cod....

===================================================

UPDATE `configuration` SET `configuration_title` = 'Points per ?1 purchase',

`use_function` = NULL ,

`set_function` = NULL WHERE configuration_id` =191 LIMIT 1;

 

UPDATE `configuration` SET `configuration_title` = '? Redeem per point',

`use_function` = NULL ,

`set_function` = NULL WHERE `configuration_id` =192 LIMIT 1;

===================================================

 

what makes you so sure that  other users configuration_id value match your value configuration_id` =191 ??????.

and im really wondering, applying this change made any diff in the way this module deals with the values for corrency????

It shows YEN but cosider it  $, EURO, YEN POND RUPPIES, PESSOS, or whatever currency you want it will always used the default currency defined by admin.

But go ahead and change it if its make you sleep better. :thumbsup:

Edited by fatmcgav
Link to comment
Share on other sites

Both of you guys did a great job especially the original author who created it. Remember this is open source and we are all part of a team. Just look at all the other contributions where authors have come in and updated contributions or made improvements.

 

The fact is, thanks always goes to the original author for creating the contribution in the first place. :D

Link to comment
Share on other sites

This contribution looks great!

I have a question however: if you set a minimal amount of points before they can be redeemed, does it apply only for the first time the customer uses his points?

I mean, the customer reaches 200 points, which is the limit (for instance), then uses his 200 points. Does he have to reach 200 points again in order to get the next redeem ? Or does the limit apply only once? (Once you have crossed the 200 points limit, no further limit applies?)

Sorry for my english, I hope you understand my question :-"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...