Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Converting Points and Rewards system for osC BS


Tsimi

Recommended Posts

Link to comment
Share on other sites

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

@Tsimi on the last bug are you seeing an error? If so can you screen print it and send to me?

Link to comment
Share on other sites

55 minutes ago, LeeFoster said:

@Tsimi on the last bug are you seeing an error? If so can you screen print it and send to me?

Never mind I found a fix.

This 

#####  BOF POINTS REWARDS BS  #######
  if ((MODULE_HEADER_TAGS_POINTS_REWARDS_USE_POINTS_SYSTEM == 'True') && (MODULE_HEADER_TAGS_POINTS_REWARDS_USE_REDEEM_SYSTEM == 'True')) {
	  if (isset($_POST['customer_shopping_points_spending']) && is_numeric($_POST['customer_shopping_points_spending']) && ($_POST['customer_shopping_points_spending'] > 0)) {
		  $customer_shopping_points_spending = false;
		  // This if sentence should include check for amount of points on account compared to the transferred point from checkout_payment.php
		  // Possible Hack Fix included
		  if (tep_calc_shopping_pvalue($_POST['customer_shopping_points_spending']) < $order->info['total'] && !is_object($$payment) || (tep_get_shopping_points($customer_id) < $_POST['customer_shopping_points_spending'])) {
			  $customer_shopping_points_spending = false;
			  tep_redirect(tep_href_link('checkout_payment.php', 'error_message=' . urlencode(REDEEM_SYSTEM_ERROR_POINTS_NOT), 'SSL'));
		  } else {
			  $customer_shopping_points_spending = $_POST['customer_shopping_points_spending'];
			  if (!tep_session_is_registered('customer_shopping_points_spending')) tep_session_register('customer_shopping_points_spending');
		  }
	  }
	  
	  //To ensure only the first order of a new customer is entitled to grant point to his/her referrer. Otherwise, a hacker might hard-code the email address of  a referrer and cheat for point on every single order the new customer made.
	  if (tep_not_null(MODULE_HEADER_TAGS_POINTS_REWARDS_POINTS_USE_REFERRAL_SYSTEM) && (tep_count_customer_orders() == 0)) {
		  if (isset($_POST['customer_referred']) && tep_not_null($_POST['customer_referred'])) {
			  $customer_referral = false;
			  $check_mail = trim($_POST['customer_referred']);
			  if (tep_validate_email($check_mail) == false) {
				  tep_redirect(tep_href_link('checkout_payment.php', 'error_message=' . urlencode(REFERRAL_ERROR_NOT_VALID), 'SSL'));
			  } else {
				  $valid_referral_query = tep_db_query("select customers_id from customers where customers_email_address = '" . $check_mail . "' limit 1");
				  $valid_referral = tep_db_fetch_array($valid_referral_query);
				  if (!tep_db_num_rows($valid_referral_query)) {
					  tep_redirect(tep_href_link('checkout_payment.php', 'error_message=' . urlencode(REFERRAL_ERROR_NOT_FOUND), 'SSL'));
				  }
				  
				  if ($check_mail == $order->customer['email_address']) {
					  tep_redirect(tep_href_link('checkout_payment.php', 'error_message=' . urlencode(REFERRAL_ERROR_SELF), 'SSL'));
				  } else {
					  $customer_referral = $valid_referral['customers_id'];
					  if (!tep_session_is_registered('customer_referral')) tep_session_register('customer_referral');
				  }
			  }
		  }
	  }
  }
  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'));
  }
########  EOF POINTS REWARDS BS #################*/

Should be this.

 #####  BOF POINTS REWARDS BS  #######
  if ((USE_POINTS_SYSTEM == 'true') && (USE_REDEEM_SYSTEM == 'true')) {
	  if (isset($_POST['customer_shopping_points_spending']) && is_numeric($_POST['customer_shopping_points_spending']) && ($_POST['customer_shopping_points_spending'] > 0)) {
		  $customer_shopping_points_spending = false;
		  // This if sentence should include check for amount of points on account compared to the transferred point from checkout_payment.php
		  // Possible Hack Fix included
		  if (tep_calc_shopping_pvalue($_POST['customer_shopping_points_spending']) < $order->info['total'] && !is_object($$payment) || (tep_get_shopping_points($customer_id) < $_POST['customer_shopping_points_spending'])) {
			  $customer_shopping_points_spending = false;
			  tep_redirect(tep_href_link('checkout_payment.php', 'error_message=' . urlencode(REDEEM_SYSTEM_ERROR_POINTS_NOT), 'SSL'));
		  } else {
			  $customer_shopping_points_spending = $_POST['customer_shopping_points_spending'];
			  if (!tep_session_is_registered('customer_shopping_points_spending')) tep_session_register('customer_shopping_points_spending');
		  }
	  }
	  
	  //To ensure only the first order of a new customer is entitled to grant point to his/her referrer. Otherwise, a hacker might hard-code the email address of  a referrer and cheat for point on every single order the new customer made.
	  if (tep_not_null(USE_REFERRAL_SYSTEM) && (tep_count_customer_orders() == 0)) {
		  if (isset($_POST['customer_referred']) && tep_not_null($_POST['customer_referred'])) {
			  $customer_referral = false;
			  $check_mail = trim($_POST['customer_referred']);
			  if (tep_validate_email($check_mail) == false) {
				  tep_redirect(tep_href_link('checkout_payment.php', 'error_message=' . urlencode(REFERRAL_ERROR_NOT_VALID), 'SSL'));
			  } else {
				  $valid_referral_query = tep_db_query("select customers_id from customers where customers_email_address = '" . $check_mail . "' limit 1");
				  $valid_referral = tep_db_fetch_array($valid_referral_query);
				  if (!tep_db_num_rows($valid_referral_query)) {
					  tep_redirect(tep_href_link('checkout_payment.php', 'error_message=' . urlencode(REFERRAL_ERROR_NOT_FOUND), 'SSL'));
				  }
				  
				  if ($check_mail == $order->customer['email_address']) {
					  tep_redirect(tep_href_link('checkout_payment.php', 'error_message=' . urlencode(REFERRAL_ERROR_SELF), 'SSL'));
				  } else {
					  $customer_referral = $valid_referral['customers_id'];
					  if (!tep_session_is_registered('customer_referral')) tep_session_register('customer_referral');
				  }
			  }
		  }
	  }
  }
  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'));
  }

########  EOF POINTS REWARDS BS #################*/

And in checkout_payment.php

Find

if (sizeof($selection) > 1) {
      echo tep_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $payment), 'required aria-required="true"');
    } else {
      echo tep_draw_hidden_field('payment', $selection[$i]['id']);
    }

Replace with

if (sizeof($selection) > 1) {
      echo tep_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $payment), 'aria-required="true"');
    } else {
      echo tep_draw_hidden_field('payment', $selection[$i]['id']);
    }

Something similar may also need to be done for any other 'checkout_*.php' pages.

Edited by LeeFoster
Link to comment
Share on other sites

Hello Lee @LeeFoster,

Great, but I get an error when trying to uncompress your rar. Can you please check and reload.

I'll then include it to the package as an optional module.

 

Thanks and kind regards

Rainer

Link to comment
Share on other sites

@raiwa

I'm gonna test the last bug fix from @LeeFoster now and then I would like to have a go at the shopping cart box module if that's OK with you, I think step 17?


I am sure in the history of osC people have talked about it but I can't recall any good info about it. Why do we separate the language files? Why not put all into english.php? Is it a loading speed thing? That would reduce the last 3-4 steps into 1 same for the admin change from 2 steps to 1 step.

Edited by Tsimi
Link to comment
Share on other sites

3 minutes ago, LeeFoster said:

@raiwa & @Tsimi

I'm not sure I'm going to be able to help much now until you guys have done compiling it in to a new addon. Once that's done let me know and I'll be on hand for testing and bug fixes.

Roger that will do.
Many thanks again for your interest in this addon and for your help on fixing those bugs, well done.

Edited by Tsimi
Link to comment
Share on other sites

Yes sure, here

This is how I see the payment page at first. No payment method is checked and I have ticked the checkbox below to use points

screenshot01.thumb.jpg.aa65ee51e8a38e0c6564870cb7f743d2.jpg

Then when I click on the continue button I get the typical osC error message

error_message.thumb.jpg.8c8c9e12cd942fe225fbf59f0ad51d5b.jpg

And here the checkout confirmation page, as you can see the points aren't getting deducted.

confirmation_page.thumb.jpg.a1ac6cad9a076eb4badc2b13cd458ed1.jpg

Edited by Tsimi
Link to comment
Share on other sites

1 hour ago, Tsimi said:

I am sure in the history of osC people have talked about it but I can't recall any good info about it. Why do we separate the language files? Why not put all into english.php? Is it a loading speed thing? That would reduce the last 3-4 steps into 1 same for the admin change from 2 steps to 1 step.

No need to touch this now, my goal is to move all language definitions to the new contribution language files (ht, hook, content/box modules). So in the final version there shouldn't be any language definitions left for to add to core language files.

Link to comment
Share on other sites

9 minutes ago, LeeFoster said:

Can you try un-checking the box and re-checking it to see if that resolves the issue? If not can you send me your code for checkout confirmation?

No change, issue persists.

Here my current checkout confirmation file

https://pastebin.com/1EykAeLq

This Points and Rewards addon was build on the old version of osC and I have this installed into such an old osC test shop which I used as guideline to convert it to BS. As you can see in the following screenshots the payment method is selected/ticked from the beginning and below I ticked the use points checkbox.
As you can see it automatically changes the payment method to "Points" in the checkout confirmation page.

old_osC.thumb.jpg.1827dc133e5b5cf6daf525ae05b4323f.jpg

old_osC2.thumb.jpg.d9139986b90465f4df9ebd516e55d1c0.jpg

Edited by Tsimi
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...