Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Converting Points and Rewards system for osC BS


Tsimi

Recommended Posts

51 minutes ago, raiwa said:

@burt,

2 things I found could be improved:

1. modularization as always. In that project we missed it for product_info.php, product_reviews.php, product_reviews_write.php and reviews.php

2. hooks support could be improved and included a sistematic pattern

The hooks system definitely needs to be looked at, without a doubt.  It's on the list.  The list is short as the old list was nuked.
I'd like for the hook system to be radically overhauled;  sort, pass parameters [eg for use passing the products_id at the product_listing module], have 1 hook call invoke multiple hooks (and so on)

For the modularisation...that's something that needs to be introduced to other pages.

product_info has modular (for the extras).  It also has historical code as I did not have the time to rebuild all that into modules.

the other pages don't (so far as I recall).  We probably just need a getContent call on each page (like was done for product_info) and then hope over time that modules get made to replace the historical code.

Link to comment
Share on other sites

2 minutes ago, burt said:

product_info has modular (for the extras).  It also has historical code as I did not have the time to rebuild all that into modules.

@burtThe difficulty we had (and I had similar for other add-ons) is that we wanted the content module to be displayed above the description. So an extra content call was needed. THis can only be solved if all content is modular.

Link to comment
Share on other sites

Would it be possible to see an image of that content module in place on the page.  There are ways to do it...maybe.

If I remember rightly I needed to do something halfway down the form on the create_account page
nd with a combination of .js and html, it did work well.  I think it was for that Google Address thing I made.

Link to comment
Share on other sites

@burt

Regarding that account page. Well it is somewhat modular but you need to add a piece of code to be able to show something on that page.
For example we needed to add 4 new globals and this following piece of code to be able to show the points and rewards part on the account page.

// BOF POINTS REWARDS BS //-->
    if (MODULE_HEADER_TAGS_POINTS_REWARDS_USE_POINTS_SYSTEM == 'True') {
      
    require('includes/languages/' . $language . '/modules/pages/tp_account.php');
    
    require_once('includes/functions/redemptions.php');
		
	$output .= '<h2>' . TP_ACCOUNT_MY_POINTS_TITLE . '</h2>
           <div class="contentText">  
			  <ul class="list-unstyled">';

  $has_points = tep_get_shopping_points($customer_id);
  if ($has_points > 0) {
	  $output .= '<h4><span class="label label-info">' . sprintf(TP_ACCOUNT_MY_POINTS_CURRENT_BALANCE, number_format($has_points, MODULE_HEADER_TAGS_POINTS_REWARDS_POINTS_POINTS_DECIMAL_PLACES), $currencies->format(tep_calc_shopping_pvalue($has_points))) . '</span></h4>';
  }
	$output .= '<li><i class="fa fa-plus"></i> <a href="' . tep_href_link('my_points.php', '', $request_type) . '">' . TP_ACCOUNT_MY_POINTS_VIEW . '</a></li>    
				<li><i class="fa fa-info-circle"></i> <a href="' . tep_href_link('my_points_help.php', '', $request_type) . '">' . TP_ACCOUNT_MY_POINTS_VIEW_HELP . '</a></li>
			  </ul>
           </div>'; 
  }
// EOF POINTS REWARDS BS //--> 

It is not really much but it is "touching core code" and that is what we try to avoid as much as possible. Even though this is just a code addition and not a code replacement or core code change.

If that account page would be same modular as the navbar or header we could have all those elements (My Account, My Orders, E-Mail Notifications) as modules, give them a sort order and rearrange that page to what ever we like. Need a new "group"? Drop in module, install, set sort order done.
Lot easier don't you think? If I wanted to change the way that page look I would need to touch the tp_account.php code which is not ideal, I think.

Link to comment
Share on other sites

@raiwa

I just finished converting all image buttons to jquery UI buttons.
Also fixed/adjusted the text for English, German and Spanish to match/fit the new buttons.

I will submit a pull request shortly then you can take a look at it if time allows.

Regarding the copyright sample I will get that done tomorrow if that's OK.

Also something I encountered and would like anyone to check and confirm this errors.

On the Referral page admin I get these errors

admin/customers_points_referral.php

Quote

 

Warning: strtolower() expects parameter 1 to be string, object given in C:\xampp\htdocs\demo6\admin\includes\functions\general.php on line 327

Warning: trim() expects parameter 1 to be string, object given in C:\xampp\htdocs\demo6\admin\includes\functions\general.php on line 327

 

On the Pending page admin area I get these errors

admin/customers_points_pending.php

When deleting points I get this error on the delete confirmation

Quote

 

Warning: in_array() expects parameter 2 to be array, string given in C:\xampp\htdocs\demo6\admin\includes\functions\general.php on line 127

Warning: in_array() expects parameter 2 to be array, string given in C:\xampp\htdocs\demo6\admin\includes\functions\general.php on line 127

Warning: in_array() expects parameter 2 to be array, string given in C:\xampp\htdocs\demo6\admin\includes\functions\general.php on line 127

 

 

Edited by Tsimi
Link to comment
Share on other sites

9 minutes ago, Tsimi said:

Also something I encountered and would like anyone to check and confirm this errors.

On the Referral page admin I get these errors

admin/customers_points_referral.php

On the Pending page admin area I get these errors

admin/customers_points_pending.php

When deleting points I get this error on the delete confirmation

 

I got those errors too, it's because there are no pending or referral points. 

I belive these 2 pages could be just one merged page though.

Link to comment
Share on other sites

7 minutes ago, Tsimi said:

@burt

Regarding that account page.  ...

Need a new "group"? Drop in module, install, set sort order done.
Lot easier don't you think? If I wanted to change the way that page look I would need to touch the tp_account.php code which is not ideal, I think.

The account page (although it does look different) is modular.  Go into admin and (eg) turn on the "set password" module.  This module adds in a link to the set password page.

To test it ....

login as a customer, navigate to account page.
login to admin, make sure set password module is OFF

log into phpmyadmin, null the password for the customer you are logged in as
in admin turn on the set password module

Now a link shows in the account.

The only perceived problem is that the module output should be a list item.

I do something very similar (to your points/rewards bit) in that code block I previously posted - that code block is for showing a credit balance in the account page (in a new group!)...

 

Hope it makes sense ?  If I can find time I will try an installation of yours and rewrite it and see if I can get the output correct (which will then save a potential code change).

Link to comment
Share on other sites

@burt

Interesting...

I still have your files. I will go through them and see how you did it.
Now I am gonna grab a glass of nice red vine and watch "The Expanse", which I can highly recommend. The next best Sci-Fi thing to Star Trek: Discovery or maybe even better.

 

Sorry, went a bit off topic there... :happy:

Edited by Tsimi
Link to comment
Share on other sites

@Tsimi, I pushed an update for the info text in product info and reviews modules.

I changed the styling to alert, like this the text breaks in several lines on small devices. Please have a look if you like it like this.

I found that in the german files the install check texts are missing in all modules.

tks and best regards

Rainer

Link to comment
Share on other sites

@raiwa

I merged your latest changes manually and added the missing install check messages into all necessary module language files.
I added a pull request but github says there is a conflict with one of the German language files, not sure exactly what is not matching, but only you can fix it since you are the one with write permission.

 

Link to comment
Share on other sites

@Tsimi,

pushed the fix for the warning message in: admin/customers_points_referral.php

I couldn't recreate the other in admin/customers_points_pending.php, could you check again and describe when exact you get it.

Link to comment
Share on other sites

@burt

I was trying to implement that account part as module.

I was able to show the title and 1 row of text with link.

Our Points and Rewards system normally should show 3 rows and 1 title inside the account area.
All the account modules that are available to me as reference only show how to implement 1 row and 1 title only.

How can I add more rows? Do I need a module for each row?

Edited by Tsimi
Link to comment
Share on other sites

@burt

Small update regarding the account stuff.

I was able to show now all 3 rows that we need. I needed to use links inside the language file which I am not sure is the right way.
Here the code I used

    function execute() {
        global $oscTemplate, $language, $customer_id, $currencies;
      
		if (MODULE_HEADER_TAGS_POINTS_REWARDS_USE_POINTS_SYSTEM == 'True') {
			
		    require_once('includes/functions/redemptions.php');
			
			$has_points = tep_get_shopping_points($customer_id);	
		    $oscTemplate->_data['account']['tags']['title'] = MODULE_CONTENT_ACCOUNT_POINTS_TITLE;
		    $oscTemplate->_data['account']['tags']['links']['tag'] = array('title' => '<h4><span class="label label-info">' . sprintf(MODULE_CONTENT_ACCOUNT_POINTS_CURRENT_BALANCE, number_format($has_points, MODULE_HEADER_TAGS_POINTS_REWARDS_POINTS_POINTS_DECIMAL_PLACES), $currencies->format(tep_calc_shopping_pvalue($has_points))) . '</span></h4>' . TEST,
																		   'link' => NULL,
																		   'icon' => NULL);
		}
	 
    }

and the language file

  define('MODULE_CONTENT_ACCOUNT_POINTS_TITLE', 'My Points and Redemptions');
  define('MODULE_CONTENT_ACCOUNT_POINTS_DESCRIPTION', 'Shows Points and Rewards block on account.php page');

  define('MODULE_CONTENT_ACCOUNT_POINTS_PUBLIC_TITLE', 'My Points and Redemptions');
  
  define('MODULE_CONTENT_ACCOUNT_POINTS_CURRENT_BALANCE', 'Shopping Points Balance : %s points. Valued at : %s ');
  
  define('MODULE_CONTENT_ACCOUNT_POINTS_VIEW', 'View my Points Balance and Points received.');
  
  define('MODULE_CONTENT_ACCOUNT_POINTS_VIEW_HELP', 'Reward Point Program FAQ.');

  define('TEST', '<i class="fa fa-plus"></i> <a href="' . tep_href_link('my_points.php', '', 'SSL') . '">' . MODULE_CONTENT_ACCOUNT_POINTS_VIEW . '</a><br><i class="fa fa-info-circle"></i> <a href="' . tep_href_link('my_points_help.php', '', 'SSL') . '">' . MODULE_CONTENT_ACCOUNT_POINTS_VIEW_HELP . '</a>');

As you can see I used the TEST definition to add the additional 2 rows.
Too bad that we cannot set the sort order for the whole block. I don't really like it being at the most top. But maybe that is just me.

account_points.jpg.9a9f62ec6bc3594669e1436d403956fa.jpg

Link to comment
Share on other sites

@burt

Never mind the links in the language files I moved them to the module.
So only thing left is the sort order. Is there any way to get that to work? Move the Points block to the most bottom.

@raiwa

What do you think? Does it matter if the Points and Rewards block is at the top or should it be at the bottom?

 

Link to comment
Share on other sites

@Tsimi,

if possible, better on the bottom.

Could this work:

    function execute() {
        global $oscTemplate, $language, $customer_id, $currencies;
      
        if (MODULE_HEADER_TAGS_POINTS_REWARDS_USE_POINTS_SYSTEM == 'True') {
			
          require_once('includes/functions/redemptions.php');
			
          $oscTemplate->_data[['account']['tags']] = array('account' => array('title' => MODULE_CONTENT_ACCOUNT_POINTS_TITLE,
                                                                       'sort_order' => 50,
                                                                       'links' => array('points' => array('title' => '<h4><span class="label label-info">' . sprintf(MODULE_CONTENT_ACCOUNT_POINTS_CURRENT_BALANCE, number_format($has_points, MODULE_HEADER_TAGS_POINTS_REWARDS_POINTS_POINTS_DECIMAL_PLACES), $currencies->format(tep_calc_shopping_pvalue($has_points)))),
                                                                                                        'link' => null,
                                                                                                        'icon' => null),
                                                                                    'view' => array('title' => MODULE_CONTENT_ACCOUNT_POINTS_VIEW,
                                                                                                            'link' => tep_href_link('my_points.php', '', 'SSL'),
                                                                                                            'icon' => 'fa fa-plus'),
                                                                                    'view_help' => array('title' => MODULE_CONTENT_ACCOUNT_POINTS_VIEW_HELP,
                                                                                                            'link' => tep_href_link('my_points_help.php', '', 'SSL'),
                                                                                                            'icon' => 'fa fa-circle'));
				}
	 
    }

Didn't test in practice, if you post your entire modules, I would try. Maybe this is not corrrect: "$oscTemplate->_data[['account']['tags']] =" do not know yet how exact it works.

Edited by raiwa
Link to comment
Share on other sites

@raiwa

Tried your suggestion but no luck.
Here the module if you want to give it another try.

account module.zip

I also prefer the Points and Rewards part to be at the bottom of the account page.
If we cannot reach that then we should stick with the code change as is in install step 1

Edited by Tsimi
Link to comment
Share on other sites

Found a dirty solution.
Now the module contents shows at the most bottom or better said after the E-Mail Notifications part.

The default account page is build with 3 blocks/groups "account", "orders", and "notifications"

The following module code will add the Points and Rewards block after the notifications block.

    function execute() {
        global $oscTemplate, $language, $customer_id, $currencies;
    
		if (MODULE_HEADER_TAGS_POINTS_REWARDS_USE_POINTS_SYSTEM == 'True') {
			
		    require_once('includes/functions/redemptions.php');
			
			$has_points = tep_get_shopping_points($customer_id);	
			$oscTemplate->_data['account']['notifications']['links']['points_title'] = array('title' => '<h2>' . MODULE_CONTENT_ACCOUNT_POINTS_TITLE . '</h2>',
																							 'link' => NULL,
																							 'icon' => NULL);																		   
			$oscTemplate->_data['account']['notifications']['links']['points'] = array('title' => '<div class="alert alert-info">' . sprintf(MODULE_CONTENT_ACCOUNT_POINTS_CURRENT_BALANCE, number_format($has_points, MODULE_HEADER_TAGS_POINTS_REWARDS_POINTS_POINTS_DECIMAL_PLACES), $currencies->format(tep_calc_shopping_pvalue($has_points))) . '</div>',
																							 'link' => NULL,
																							 'icon' => NULL);	
			$oscTemplate->_data['account']['notifications']['links']['view'] = array('title' => MODULE_CONTENT_ACCOUNT_POINTS_VIEW,
																							 'link' => tep_href_link('my_points.php', '', 'SSL'),
																							 'icon' => 'fa fa-plus');	
			$oscTemplate->_data['account']['notifications']['links']['view_help'] = array('title' => MODULE_CONTENT_ACCOUNT_POINTS_VIEW_HELP,
																							 'link' => tep_href_link('my_points_help.php', '', 'SSL'),
																							 'icon' => 'fa fa-info-circle');																		   
		}
    }

If you change ['notifications'] to ['account'] or ['orders'] it will show below those groups. Make sense?
If I use ['tags'] it will show the Points and Rewards block at the most top which is what we want to avoid.

Edited by Tsimi
Link to comment
Share on other sites

Give it a totally different name, which will add it to the array in a new bloc...and give it a sort order higher than 30...

Note that the array must be built like the ones already existing, eg:

https://github.com/gburton/Responsive-osCommerce/blob/master/includes/modules/pages/tp_account.php#L30-L34

title
sort_order
links(xyz(title, link, icon)

Link to comment
Share on other sites

UPDATE!

Never mind. I got it! Heureka!

God how could I miss that.

Here is the code that works

    function execute() {
        global $oscTemplate, $language, $customer_id, $currencies;
    
		if (MODULE_HEADER_TAGS_POINTS_REWARDS_USE_POINTS_SYSTEM == 'True') {
			
		    require_once('includes/functions/redemptions.php');
			
			$has_points = tep_get_shopping_points($customer_id);	
			$oscTemplate->_data[$this->group] += array('points' => array('title' => MODULE_CONTENT_ACCOUNT_POINTS_TITLE,
                                                                   'sort_order' => MODULE_CONTENT_ACCOUNT_POINTS_SORT_ORDER,
                                                                   'links' => array('points_balance' => array('title' => '<div class="alert alert-info">' . sprintf(MODULE_CONTENT_ACCOUNT_POINTS_CURRENT_BALANCE, number_format($has_points, MODULE_HEADER_TAGS_POINTS_REWARDS_POINTS_POINTS_DECIMAL_PLACES), $currencies->format(tep_calc_shopping_pvalue($has_points))) . '</div>',
                                                                                                              'link' => NULL,
                                                                                                              'icon' => NULL),
                                                                                    'view' => array('title' => MODULE_CONTENT_ACCOUNT_POINTS_VIEW,
                                                                                                    'link' => tep_href_link('my_points.php', '', 'SSL'),
                                                                                                    'icon' => 'fa fa-plus'),
                                                                                    'view_help' => array('title' => MODULE_CONTENT_ACCOUNT_POINTS_VIEW_HELP,
                                                                                                         'link' => tep_href_link('my_points_help.php', '', 'SSL'),
                                                                                                         'icon' => 'fa fa-info-circle'))));
																	   
		}
    }

I just needed to add a + before the array code.

$oscTemplate->_data[$this->group] += array('points' => etc....

also added this

'sort_order' => MODULE_CONTENT_ACCOUNT_POINTS_SORT_ORDER,

now the sort order can be set via admin module settings.

Edited by Tsimi
Link to comment
Share on other sites

@raiwa

I was just adding the module warning messages into this account module when I realized that your module (HT) injects/adds the hooks codes automatically into all necessary files when installing the HT module. Holy shit! THAT is some genius work there. I didn't realize that till today. :blush:

That will reduce the install manual to a few lines of text, lol
How the hell did you get that idea to add code lines like that? That is really cool.
Last time I had seen something like that was with the Discount Codes BS addon but that was only a piece of code into one file.

Well done!

Edited by Tsimi
Link to comment
Share on other sites

3 minutes ago, Tsimi said:

@raiwa

I was just adding the module warning messages into this account module when I realized that your module (HT) injects/adds the hooks codes automatically into all necessary files when installing the HT module. Holy shit! THAT is some genius work there. I didn't realize that till today. :blush:

That will reduce the install manual to a few lines of text, lol
How the hell did you get that idea to add code lines like that? That is really cool.
Last time I had seen something like that was with the Discount Codes BS addon but that was only a piece of code into one file.

Well done!

Thanks, the base idea was copied from the administrator .htaccess password protection and I applied it already in the store mode and sloppy words cleaner add-ons.

But I guess mailbizz and paypal app are doing it similar.

Link to comment
Share on other sites

35 minutes ago, Tsimi said:

UPDATE!

Never mind. I got it! Heureka!

God how could I miss that.

Here is the code that works


    function execute() {
        global $oscTemplate, $language, $customer_id, $currencies;
    
		if (MODULE_HEADER_TAGS_POINTS_REWARDS_USE_POINTS_SYSTEM == 'True') {
			
		    require_once('includes/functions/redemptions.php');
			
			$has_points = tep_get_shopping_points($customer_id);	
			$oscTemplate->_data[$this->group] += array('points' => array('title' => MODULE_CONTENT_ACCOUNT_POINTS_TITLE,
                                                                   'sort_order' => MODULE_CONTENT_ACCOUNT_POINTS_SORT_ORDER,
                                                                   'links' => array('points_balance' => array('title' => '<div class="alert alert-info">' . sprintf(MODULE_CONTENT_ACCOUNT_POINTS_CURRENT_BALANCE, number_format($has_points, MODULE_HEADER_TAGS_POINTS_REWARDS_POINTS_POINTS_DECIMAL_PLACES), $currencies->format(tep_calc_shopping_pvalue($has_points))) . '</div>',
                                                                                                              'link' => NULL,
                                                                                                              'icon' => NULL),
                                                                                    'view' => array('title' => MODULE_CONTENT_ACCOUNT_POINTS_VIEW,
                                                                                                    'link' => tep_href_link('my_points.php', '', 'SSL'),
                                                                                                    'icon' => 'fa fa-plus'),
                                                                                    'view_help' => array('title' => MODULE_CONTENT_ACCOUNT_POINTS_VIEW_HELP,
                                                                                                         'link' => tep_href_link('my_points_help.php', '', 'SSL'),
                                                                                                         'icon' => 'fa fa-info-circle'))));
																	   
		}
    }

I just needed to add a + before the array code.

$oscTemplate->_data[$this->group] += array('points' => etc....

also added this


'sort_order' => MODULE_CONTENT_ACCOUNT_POINTS_SORT_ORDER,

now the sort order can be set via admin module settings.

Fantastic, push it right now! :smile:

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