Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Converting Points and Rewards system for osC BS


Tsimi

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

 

Link to comment
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

Link to comment
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?

 

Link to comment
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

 

Link to comment
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

Link to comment
Share on other sites

Link to comment
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
Link to comment
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']));
          }

 

Link to comment
Share on other sites

Link to comment
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
Link to comment
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. 

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.
Note: Your post will require moderator approval before it will be visible.

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