Jump to content
Tsimi

Converting Points and Rewards system for osC BS

Recommended Posts

If I do 

Quote

CATALOG STEP = 4.   open catalog/checkout_payment.php
This will add the javascript alart checking the box for invalid character. As well as 
allow points to be used as payment method.

**This step has 2 parts

FIND:

  require('includes/template_top.php');
?>

ADD AFTER IT:

/*  BOF POINTS REWARDS BS  */
var submitter = null;
function submitFunction() {
   submitter = 1;
   }
/*  EOF POINTS REWARDS BS  */

I just see plain text. If I put it inside ?> then I get the below 

Quote

Parse error: syntax error, unexpected 'var' (T_VAR) in E:\xampp\htdocs\generic\checkout_payment.php on line 91

 

Share this post


Link to post
Share on other sites

@Tsimi

I have a fix for error one.

in admin/customer_points.php on line 162 

Find 

if (isset($_POST['queue_add']) && ($_POST['queue_add'] == 'on')) {

Replace with 

if (isset($_POST['queue_delete']) && ($_POST['queue_delete'] == 'on')) {

Share this post


Link to post
Share on other sites

Hello @Tsimi,

I did a test installation on the latest EDGE under PHP 7.1.

I stillget a bunch of undefined and other errors in:

admin/customers_points.php

admin/customers_points_pending.php

admin/customers_points_referral.php

I'll go step by step to clean up this.

For now I revised the complete installation and checked what can be moved into header tag and hook.

Here my comments:

CATALOG STEP = 1.   open catalog/includes/modules/pages/tp_account.php

- add modified module

open catalog/checkout_confirmation.php (should be step 2)   CATALOG STEP = 3.

this snippet of the replace code:

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

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

  }

should be updated to:

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

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

  }

The entire code could be moved to a header tag module.

open catalog/checkout_payment.php   CATALOG STEP = 4.

missing <script> tags:

<script>

/*  BOF POINTS REWARDS BS  */

var submitter = null;

function submitFunction() {

   submitter = 1;

   }

/*  EOF POINTS REWARDS BS  */

</script>

missing tags:

      </tbody>

    </table>

 

  </div>

The entire code can be moved into a hook

open catalog/checkout_process.php   CATALOG STEP = 5.

Can be moved into hooks (3 functions)

open catalog/create_account.php   CATALOG STEP = 6.

Can be moved into hook

open catalog/create_account_success.php   CATALOG STEP = 7.

find snippet is:

<div class="contentContainer">

  <div class="contentText">

    <div class="alert alert-success">

      <?php echo TEXT_ACCOUNT_CREATED; ?>

Can be moved into hook

open catalog/logoff.php   CATALOG STEP = 8.

clean indents (no indents)

can be moved into header tag.

CATALOG STEP = 11.   open catalog/product_info.php

Can be moved into hook

CATALOG STEP = 12.   open catalog/product_reviews.php

Can be moved into hook

CATALOG STEP = 13.   open catalog/product_reviews_write.php

first part can be moved into header tag

second part into hook

CATALOG STEP = 14.   open catalog/reviews.php

Can be moved into hook

CATALOG STEP = 15.   open catalog/includes/application_top.php

needs to be tested, but should be possible to include in header tag

CATALOG STEP = 16.    open catalog/includes/modules/boxes/templates/information.php

- missing indent

- include modified box

- better include in the footer information module

CATALOG STEP = 17.    open catalog/includes/modules/boxes/bm_shopping_cart.php(optional)

- include modified box

- better include in the navbar module

CATALOG STEP = 18.   open catalog/includes/classes/payment.php

Maybe could be done with a drop in payment class extension instantiated in header tag

CATALOG STEP 19-25 language definitions

could be moved into header tag/hooks

ADMIN:

ADMIN STEP = 1.   open admin/orders.php

Can be moved into hooks

ADMIN STEP = 2.   open admin/includes/functions/general.php

keep as is

ADMIN STEP = 3.   open admin/includes/languages/english.php

keep as is

ADMIN STEP = 4.   open admin/includes/languages/english/orders.php

move to hook

 

NOTE: Hooks need still core file modifications for hook register and calls. But it could be done in a install script. I have one example for this in the sloppy words cleaner contribution. Please have a look how it is done there and let me know what you think about.

Sloppy Words Cleaner reloaded

 

If you agree I then begin to create the header tag and hooks. Be patient, it will need time.

 

Rgds

Rainer

Share this post


Link to post
Share on other sites

@raiwa

Hi Rainer

I had a look at your Sloppy Words Cleaner addon and boy that is some code you created there for the hooks. How the hell could you keep an overview, well done.
Something like that would be fantastic.

You mention a couple of header tags so you mean every code change will have its own header tags module or is all gonna fit into 1-2 header tags modules?

 

Share this post


Link to post
Share on other sites

Hello @Tsimi,

9 hours ago, Tsimi said:

You mention a couple of header tags so you mean every code change will have its own header tags module or is all gonna fit into 1-2 header tags modules?

I would fit all in one header tag and then use switch basename($PHP_SELF) to include the required code for the pages.

The header tag would be the main module for the contribution, including all the configuration entries, installation scripts etc.

I suggest to create a GIT HUB repository, starting with your BETA version and applying the already found bug fixes and so on.

Steps proposal:

- fixes for undefined errors (already partly done)

- fixes for known bugs like the one posted by @LeeFoster

- create header tag module:

  • - add installation scripts for database
  • - add configuration entries
  • - add code for the pages where it is possible and remove from core files
  • - add language definitions to header tag language file where possible

- create hook:

  • add functions for the pages where it makes sense and remove code changes from core files
  • add language definitions to hook language file and remove from core language files

- create modified content modules to replace core modules

- revise all html tags for BS integration

- add installation script to header tag module (hooks register and calls)

Let me know what you and others think about.

rgds

Rainer

 

Share this post


Link to post
Share on other sites

@raiwa

Sounds like a good and well thought out plan. :thumbsup:

So how do we proceed? You make the changes step by step and we test or should we also try to make some changes and send you a pull request?

Edited by Tsimi

Share this post


Link to post
Share on other sites

@Tsimi,

As you wish, have time and feel this is a job for you.

I'm still "polishing" undefined errors. Just let a Note if you take over a task to avoid duplicate jobs.

rgds

Rainer

Share this post


Link to post
Share on other sites

Added to GIT "To do" list (Readme file) with tasks asigend.

Share this post


Link to post
Share on other sites

@raiwa

Please ignore my github stuff. I was just testing things out. Sorry about that.
I don't know how to handle the github stuff so good yet. I wanted to merge your latest commits with my fork and eventually figured it out but my commits were uploaded with my other github account. I have 2 github accounts and want to keep them separated. At the end I just deleted everything and will start from scratch again.

I will redo the changes tomorrow and add a pull request.

I fix the manual step numbers, the missing script tag and the code fix inside the checkout confirmation and checkout payment.
Btw. LeeFosters bug fix has two instances and I think both need to be replaced.

 

Edited by Tsimi

Share this post


Link to post
Share on other sites

I have managed to find a fix to bug 3.

In admin/customers_points.php

Find 

if ($pointstodel > 0) {
          if (isset($_POST['set_exp']) && ($_POST['set_exp'] == 'on') && ($balance > 0)) {
            $expire  = date('Y-m-d', strtotime('+ '. POINTS_AUTO_EXPIRES .' month'));
            $expire_date = "\n" . sprintf(EMAIL_TEXT_EXPIRE, tep_date_short($expire));
	        tep_db_query("update customers set customers_shopping_points = customers_shopping_points - '". $pointstodel ."', customers_points_expires = '". $expire ."' where customers_id = '". (int)$customers_id ."'");
          } else {
	        $exp = ($balance > 0) ? $Cexpire_date : 'null';
	        tep_db_query("update customers set customers_shopping_points = customers_shopping_points - '". $pointstodel ."' where customers_id = '". (int)$customers_id ."'");
            $expire_date = "\n" . sprintf(EMAIL_TEXT_EXPIRE, tep_date_short($_POST['customers_points_expires']));
          }

Replace with

if ($pointstodel > 0) {
          if (isset($_POST['set_exp']) && ($_POST['set_exp'] == 'on') && ($balance > 0)) {
            $expire  = date('Y-m-d', strtotime('+ '. POINTS_AUTO_EXPIRES .' month'));
            $expire_date = "\n" . sprintf(EMAIL_TEXT_EXPIRE, tep_date_short($expire));
	        tep_db_query("update customers set customers_shopping_points = customers_shopping_points - '". $pointstodel ."', customers_points_expires = '". $expire ."' where customers_id = '". (int)$customers_id ."'");
          } else if (isset($_POST['set_exp']) && ($_POST['set_exp'] == 'on') && ($balance == '0')) {
            $expire  = null;
            $expire_date = "\n" . sprintf(EMAIL_TEXT_EXPIRE, tep_date_short($expire));
	        tep_db_query("update customers set customers_shopping_points = customers_shopping_points - '". $pointstodel ."', customers_points_expires = '". $expire ."' where customers_id = '". (int)$customers_id ."'");
          } else {
	        $exp = ($balance > 0) ? $Cexpire_date : 'null';
	        tep_db_query("update customers set customers_shopping_points = customers_shopping_points - '". $pointstodel ."' where customers_id = '". (int)$customers_id ."'");
            $expire_date = "\n" . sprintf(EMAIL_TEXT_EXPIRE, tep_date_short($_POST['customers_points_expires']));
          }

 

Share this post


Link to post
Share on other sites

@Tsimi, can you confirm and take care of it -> pull reuqest?

Share this post


Link to post
Share on other sites

@raiwa

Roger that. Will do.
I am setting up Sourcetree and fork again as we speak.

I just need to figure out how to keep my two github accounts separated when adding commits and pull requests.

Share this post


Link to post
Share on other sites

I couldn't figure out how to use my Tsimi78 github account so I just use my other one.

I use the same avatar as in this forum.

Edited by Tsimi

Share this post


Link to post
Share on other sites
Just now, Tsimi said:

@LeeFoster

The fix for bug #3 doesn't work for me.
I still have the last set expire date showing even if the points are 0

Can you check your database table for customer and make sure customer_id is both primary and auto increment. This was an issue for me but I just assumed it was my database.

Share this post


Link to post
Share on other sites
Just now, Tsimi said:

Never mind. It does work.
I didn't click the "adjust" button, I used the "delete points" button DUH!

Delete points should also do it.

Share this post


Link to post
Share on other sites

Really? It doesn't work with delete points... but before I say something too early again let me try it out again.

Edited by Tsimi

Share this post


Link to post
Share on other sites

Yep, you're right it does work if you tick the new expire date checkbox.
Well done. Code will be added to github.

You sure are more skilled then you like to admit. :wink:

2 bugs down 1 last one to go for now.

Edited by Tsimi

Share this post


Link to post
Share on other sites
4 minutes ago, Tsimi said:

Yep, you're right it does work if you tick the new expire date checkbox.
Well done. Code will be added to github.

You sure are more skilled then you like to admit. :wink:

2 bugs down 1 last one to go for now.

I'm OK at fixing other people's code but useless at writing my own. 

I'm looking at the last bug now, it looks like the java script isn't being triggered. 

Share this post


Link to post
Share on other sites

@raiwa

Not sure if I do something wrong but it looks like I cannot add another pull request for the bug 1 and 3 fixes.

Maybe if you accept the one that is currently open I can create a new one?

Man that github is so damn complicate.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×