Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Recently Viewed Products(sales optimized)


b00

Recommended Posts

Hello Dennis @@Denzel and Valquiria @@valquiria23,

 

Just aploaded the new version 3.4 with an alternative ht_recently_viewed module for compatibility with Modular Product Page (Bootstrap) by @@kymation: http://addons.oscommerce.com/info/9453.

 

I thought it's better to keep it as a separate alternative version instead to integrate it. As I said, there are several modular product info versions out there and one day the core will include a modular product page which may be different from kymations version.

 

Thanks again Denzel for the code and report.

 

regards

Rainer

Edited by raiwa
Link to comment
Share on other sites

@@raiwa Good job on this. Saved me a lot of bother. :)

 

I installed this in a non-BS shop because the shop owner wanted a continue shopping button with options on the shopping cart page and this was the best way to do that. The changes below should work as is but should be turned into a module to be more inline with this addon and the BS code. I thought someone might like it, though.

 

In includes/languages/english.php (any language file), add

define('IMAGE_BUTTON_CONTINUE_SHOPPING', 'Continue Shopping');

In the shopping_cart.php file, find

  <div class="buttonSet">

Replace it with

 
  <?php
         $back = sizeof($navigation->path)-2;  

          $fromHome = false;
          $fromProduct = false;
          $count = count($products);
          if( isset($products[$count-1]['id']) ) {
             if (isset($_SERVER['HTTP_REFERER'])) {
               if (strpos($_SERVER['HTTP_REFERER'], 'cPath') === FALSE) { 
                  $pathparts = pathinfo($_SERVER['HTTP_REFERER']);
                  $parts = explode('?', $pathparts['basename']);
                  $ids = explode(',', $parts[1]);
                  $fromProduct = true;
                  
                  foreach ($ids as $id) {
                      if (tep_not_null($recently_viewed_string) && strpos($recently_viewed_string, $id) !== FALSE) {
                          $fromProduct = false; //disable adding this product since it was recently viewed
                      }
                  }               
               } else  if (strpos($_SERVER['HTTP_REFERER'], 'index.php') !== FALSE) { 
                  $fromHome = true;
               }   
             }              
             
             $indexPage = '';
             if (! $fromProduct) {
                if (strpos($_SERVER['HTTP_REFERER'], 'cPath') !== FALSE) { 
                    $indexPage = 'cPath=' . tep_get_product_path(str_replace(strstr($products[$count-1]['id'], '{'), '', $products[$count-1]['id']));
                } 
             }
          }
          
          $linkArray = array();
          if (! tep_not_null($recently_viewed_string)) {
              if ($fromProduct) {
                  if (isset($parts[1])) {
                    $id = explode('=', $parts[1]);
                  } 
                  $linkArray[] = '<li><a href="' . tep_href_link($parts[0], $parts[1]) . '"><span class="hover-link">' . tep_get_products_name($id[1], $languages_id ) . '</span></a></li>';
              } else if ($fromHome) {
                  $linkArray[] = '<li><a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $continueButtonId) . '"><span class="hover-link">' . $indexPage . '</span></a></li>';
              } elseif (isset($navigation->path[$back])) {
                  $linkArray[] = '<li><a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action'))) . '"><span class="hover-link">Back</span></a></li>';
              }
          } 
          
          if (tep_not_null($recently_viewed_string)) {// && ! $fromProduct) { 
          
              $db_query = tep_db_query("select pd.products_id, pd.products_name from products p
                                     left join products_description pd on pd.products_id = p.products_id 
                                     left join specials s on s.products_id = p.products_id 
                                     where p.products_id in (" . $recently_viewed_string . ")
                                     and p.products_status = '1' 
                                     and pd.language_id = '" . (int)$languages_id . "' 
                                     limit " . MODULE_CONTENT_PRODUCT_INFO_RECENTLY_VIEWED_CONTENT_LIMIT);
                                 
              while ($db = tep_db_fetch_array($db_query)) {
                 $linkArray[] = '<li><a href="' . tep_href_link('product_info.php', 'products_id=' . $db['products_id']) .'"><span class="hover-link">' . $db['products_name'] . '</span></a></li>';
              }                 
          }
 
 ?>
   <div class="buttonSet"> 
    <?php
    echo '<div style="float:left; width:70%">';
    if (count($linkArray) < 2) {
        echo '<span class="link_button">' . tep_draw_button(IMAGE_BUTTON_CONTINUE_SHOPPING, 'glyphicon-chevron-left', tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']), 'primary', NULL, 'btn-success') . '</span>';
    } else {
        echo '<span class="link_button" >' . tep_draw_button(IMAGE_BUTTON_CONTINUE_SHOPPING, 'glyphicon-chevron-left', tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']), 'primary', NULL, 'btn-success') . 
        '<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">' .
        '<span class="caret"></span></button>
         <ul class="dropdown-menu" role="menu">';
         
         foreach ($linkArray as $link) {
            echo $link;
         }
        
         echo '</ul></span></span>';
    } 
    ?>

    <span class="text-left">
	   <?php
    $initialize_checkout_methods = $payment_modules->checkout_initialization_method();
    if (!empty($initialize_checkout_methods)) {
      reset($initialize_checkout_methods);
      while (list(, $value) = each($initialize_checkout_methods)) { ?>
	       <span class="other_options"> <?php echo $value; ?></span>
        <span class="alternate_text"><?php echo TEXT_ALTERNATIVE_CHECKOUT_METHODS; ?> </span>
    <?php  
      }
    }
    ?>  		
    </span>
    </div>

Then click around to a few products and add one to your cart. You should see the continue shopping button there.

Edited by Jack_mcs

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Thanks @@Jack_mcs,

 

This gives me the idea for a shopping cart module which could show recently viewed products (except the ones already added to cart). Maybe this could be merged together or left as 2 separate shopping cart modules.

 

rgds

Rainer

Link to comment
Share on other sites

Dear @@raiwa,

 

I just installed version 3.4 following each step.

Then I navigate between products but nothing happens.

 

When I browse my web site :  http://www.xyz.com.uy/catalog/recently_viewed.php 

 

I get the following message.
 
"Visto recientemente

No hay productos recientemente vistos a mostrar en este momento.

Esta página realiza un seguimiento de los productos más recientes que ha mirado. Puede volver a esta lista para encontrar los artículos que le interesan después de haber navegado a través de nuestra selección de productos."

 
I have installed Modular Product Page
 
any ideas ?
 
BR
 
Valqui

:heart: Community Oscommerce fan :heart: You'll find the latest osC community version here.

 

Link to comment
Share on other sites

Link to comment
Share on other sites

Dear @@raiwa

 

I install and uninstall the header tag module, but still does not work.

 

Then I install the header tag module that comes in the Upload directory (not the HT that comes in the Modular Product Page directory) and there everything works great.
 
So I understand that for some reason the HT that comes in the Modular Product Page directory is not working....
 
Any clues?
 
Best regards
 
Valqui

:heart: Community Oscommerce fan :heart: You'll find the latest osC community version here.

 

Link to comment
Share on other sites

@@valquiria23,

 

The module in product info is not a ht (header tag) module. It is a content module. Header tag modules are in includes/modules/header_tags/.

Both are needed.

 

See instructions:

 

A.  Admin > Modules > Header Tags:
    Install Module: Recently Viewed
NOTE: Installation of this Header Tags Module is required to register the visited products.
      The other 3 modules will not work without it.

o:)

Link to comment
Share on other sites

Hi @@raiwa,

 

Maybe I did not express myself very well.
 
When I install the header tag module (ht_recently_viewed.php) that comes in the "Modular Product Page by kymation\catalog\includes\modules\header_tags" , the addon did not work.
 
Then I replace the HT(ht_recently_viewed.php) with the one that came in Upload\catalog\includes\modules\header_tags and then all started to work.
 
I think the HT for Modular Product Page maybe have a problem... ??? 
 
Desde ya muchas gracias!!!
 
Beso 
 
Valqui

:heart: Community Oscommerce fan :heart: You'll find the latest osC community version here.

 

Link to comment
Share on other sites

@@valquiria23,

 

There is no ht_recently_viewed.php module in kymation's modular product page add on. The Header Tag module included there is called "ht_product_data,php" and has nothing to do with my recently viewed add-on. There is also no reference to my recently viewed add on in the modular product page instructions.

 

Anyway if it would be the case, the place for the post would be the modular product page support thread.

 

There seems to be a big confusion.

 

regards

Rainer

Edited by raiwa
Link to comment
Share on other sites

Hello Jack @@Jack_mcs,

 

The shopping cart modules are prepared if you and others would like to give it a try.

 

I finally decided to make 2 independent modules. This allows more flexibility for the shopping cart design.

For example the continue shopping and recently viewed drop down module can be placed at the top or just below the product listing and the other module at the very bottom.

The modular shopping cart is supposed to be used.

Otherwise this code should be added where the modules should show in shopping_cart.php:

  	<div class="row">
    	<?php echo $oscTemplate->getContent('shopping_cart'); ?>
    </div>

Jack, I have found one snippet in your code for which I couldn't find the use:

starting line 94 in my "cm_sc_continue_recently_viewed.php" module:

        if (! tep_not_null($recently_viewed_string)) {
        	if ($fromProduct) {
        		if (isset($parts[1])) {
        			$id = explode('=', $parts[1]);
        		} 
            $linkArray[] = '<li><a href="' . tep_href_link($parts[0], $parts[1]) . '"><span class="hover-link">' . tep_get_products_name($id[1], $languages_id ) . '</span></a></li>';
          } else if ($fromHome) {
            $linkArray[] = '<li><a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $continueButtonId) . '"><span class="hover-link">' . $indexPage . '</span></a></li>';
          } elseif (isset($navigation->path[$back])) {
            $linkArray[] = '<li><a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action'))) . '"><span class="hover-link">Back</span></a></li>';
          }
        } 

"$continueButtonId" for example isn't defined.

 

Let me know if we just can remove all that part.

 

I applied some other changes:

- remove shopping cart products from the recently product list (lines107-121)

- continue shopping button link back to index if coming from any checkout page (lines142-146)

 

Any feedback very appreciated

 

Thank You and kindest regards

Rainer

 

The package is not complete, screenshots and modular product page by kymation support is not included to save space.

The instructions are not updated yet.

 

Link to comment
Share on other sites

Hello Jack @@Jack_mcs,

 

Sorry, referenced you wrong in the before post.

Pelase see the message just before this one.

 

regards

Rainer

Edited by raiwa
Link to comment
Share on other sites

@@raiwa I saw it but haven't had time to test it. As mentioned, the shop this was added to isn't a BS shop and it has a bunch of addons involved with the shopping cart page so that might be what you are seeing. But once I test it I'll post here if I run into any problems.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Hello Jack @@Jack_mcs,

 

Meanwhile I finished all updates for a new version 4.0:

 

                Changes:
                - Added Continue shopping and recently viewed drop down shopping cart module. thanks to @@Jack_mcs
                - Added recently viewed shopping cart module.
                - Added recently viewed index nested module for modularized index page introduced to 2.3.4 BS EDGE since 12th of May 2016.
                - Added random sort order.
                - Added Microdata tags in all modules
                - all sql queries rewritten and listings code simplified in all modules.
 

If you and/or someone elsewould like to give it a try before upload.

 

 

Update: just upload the new modules and replace the main module files. No changes in templates and language files.

 

Thank You and kind regards

Rainer

Link to comment
Share on other sites

Please use this package:

 

 

 

Updated instructions and shopping_cart continue menu module

Edited by raiwa
Link to comment
Share on other sites

@@Jack_mcs and others testing the new version.

 

Found an issue with the $products variable under PHP7:

 

Under PHP before 7  (tested under 5.4, 5.5 and 5.6), the variable $products (defined within the product listing in shopping cart) shows like this when echoed: print_r($products):

only product IDs included in the array:

array(5) { [0]=> int(27) [1]=> int(23) [2]=> string(2) "26" [3]=> int(24) [4]=> string(2) "22" } 

meanwhile under PHP 7 all product details are included ( I know the ids are not the same in both examples, it's what I had copied from 2 different carts) :

array(10) { ["id"]=> int(27) ["name"]=> string(31) "Hewlett Packard LaserJet 1100Xi" ["model"]=> string(10) "HPLJ1100XI" ["image"]=> string(28) "hewlett_packard/lj1100xi.gif" ["price"]=> string(8) "499.9900" ["quantity"]=> string(1) "1" ["weight"]=> string(5) "45.00" ["final_price"]=> float(499.99) ["tax_class_id"]=> string(1) "1" ["attributes"]=> string(0) "" } [1]=> array(10) { ["id"]=> string(6) "26{3}8" ["name"]=> string(31) "Microsoft IntelliMouse Explorer" ["model"]=> string(7) "MSIMEXP" ["image"]=> string(24) "microsoft/imexplorer.gif" ["price"]=> string(7) "64.9500" ["quantity"]=> string(1) "1" ["weight"]=> string(4) "8.00" ["final_price"]=> float(64.95) ["tax_class_id"]=> string(1) "1" ["attributes"]=> array(1) { [3]=> string(1) "8" } } [2]=> array(10) { ["id"]=> int(24) ["name"]=> string(23) "Disciples: Sacred Lands" ["model"]=> string(7) "PC-DISC" ["image"]=> string(28) "gt_interactive/disciples.gif" ["price"]=> string(7) "90.0000" ["quantity"]=> string(1) "1" ["weight"]=> string(4) "8.00" ["final_price"]=> float(90) ["tax_class_id"]=> string(1) "1" ["attributes"]=> string(0) "" } [3]=> array(10) { ["id"]=> string(7) "22{5}10" ["name"]=> string(17) "Unreal Tournament" ["model"]=> string(7) "PC-UNTM" ["image"]=> string(36) "gt_interactive/unreal_tournament.gif" ["price"]=> string(7) "89.9900" ["quantity"]=> int(3) ["weight"]=> string(4) "7.00" ["final_price"]=> float(89.99) ["tax_class_id"]=> string(1) "1" ["attributes"]=> array(1) { [5]=> string(2) "10" } } } 

I needed for PHP 7 include the following compatibility layer in both shopping cart modules to get rid off the shopping cart products:

 

Here my code snippet:

        if ( MODULE_CONTENT_SHOPPING_CART_RECENTLY_VIEWED_SHOW_CURRENT == 'False' && isset($products) ) {
        	if (PHP_VERSION >= 7.0) { // PHP 7.0 includes all product data in $ products array
        		// Extract ID column
        		$products_ids = array_column($products, 'id');
        		for ($i=0, $n=sizeof($products_ids); $i<$n; $i++) {
        			// Get rid of the shopping_cart products with options
        			if ( strpos($products_ids[$i], '{') > 0 ) {
        				$products_ids[$i] = strstr($products_ids[$i], '{', true);
        			}
        		}
        	}
        	$products_string = implode(',', $products_ids);      	
        	$products_query_where .= " and p.products_id not in (" . $products_string . ")";
        }

Like this I can get under both versions a clean product id string for the sql query.

 

Not sure if there is a better way, if you have any ideas (and explanation for the issue), please let me know.

 

Here the new modified shipping cart modules:

 

 

Thank you

rgds

Rainer

Link to comment
Share on other sites

Version 4.0 BS uploaded
http://addons.oscommerce.com/info/9299

Changes:
- Added Continue shopping and recently viewed drop down menu shopping cart module. thanks to @@Jack_mcs
- Added recently viewed shopping cart module.
- Added recently viewed index nested module for modularized index page introduced to 2.3.4 BS EDGE since 12th of May 2016.
- Added random sort order.
- Added Microdata tags in all modules
- changed button icons to font awesome icons
- sql queries rewritten and listings code simplified in all modules.

 

Changes to previous Beta versions:

- "Continue Shopping" button in shopping cart module simplified

- shopping cart products exclusion in shopping cart modules updated and checked for php 5.3-5.6 and 7.0 compatibility

- micro data tags revised and tested in all modules

- installation, update and version history files updated

- all button icons updated to font awesome

 

 

Any feedback very welcome

rgds

Rainer

Edited by raiwa
Link to comment
Share on other sites

  • 2 weeks later...

@@raiwa

 

Hi Rainer

 

Just installed the latest update but have a problem. When installed "Boxes" it seems to screw my modules>boxes>install to show in part as follows

Categories   
Currencies                                 Info
Featured Products                          Info
Information                                Info
Languages                                  Info
Manufacturer Info                          Info

instead of                                                                                                                                                                                                                                       

Categories                                                                                             
Currencies                              Info
Featured Products                       Info
Information                             Info
Languages                               Info
Manufacturer Info                       Info
Reviews                                 Info
Search                                  Info
Shop by price                           Info
Module Directory: /home/XXXXX/public_html/includes/modules/boxes/

Any thoughts.(or just don't install "boxes") Everything else is fine. Ive been using this contribution for a while, maybe theres some old code I need to delete from an earlier version.

 

Cheers

 

Grandpa


 

Edited by grandpaj
Link to comment
Share on other sites

  • 8 months later...

@@raiwa

This is a great contribution!  I noticed some errors on Google's Structured data tool, so I experimented around with and I got them cleared.  Mainly it wanted position for each item in the list.  I only changed the conent/index.  Try my file below and see what you think.  The tool still shows one error, but Google help says it's a false positve.

 

 

cm_i_recently_viewed.php

I'm not really a dog.

Link to comment
Share on other sites

Hello John @@John W,

 

Thank you! I'll check this as soon as possible.

 

rgds

Rainer

Link to comment
Share on other sites

  • 6 months later...
  • 6 months later...

@raiwa @John W

On 20-4-2017 at 8:01 PM, John W said:

I noticed some errors on Google's Structured data tool, so I experimented around with and I got them cleared.  Mainly it wanted position for each item in the list.

I was thinking about this. To me it seems this doesn't need Structered Data since the content / products of recently viewed is only visible for the website customer/visitor. Google or whatever bot should / could not "see" it ...

Am I right? Thoughts?

Link to comment
Share on other sites

  • 4 weeks later...

Uploaded update:

Version 4.6 BS


Changes:        
         - Updated for 2.3.4.1. CE Frozen
         - Updated template naming and auto inclusion in all content modules
         - Added  "is-product" class and  "data-is-special"
         - Added "data-has-attributes", "data-in-stock" and "data-product-id" to "buy" buttons in all modules.

@azpro, @John W,

I checked the structured Data and the core modules throw exact the same errors so I left the code unchanged.

I believe Google sees the modules when crawling the pages, it doens't need to register account, guests see them, so why not Google after visiting some products.

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