*********************************************************************************************************************
Recently Viewed Products (sales optimized) for osCommerce 2.3.4.(1.) Bootstrap
*********************************************************************************************************************
				Version 4.6.2 BS 
				by @raiwa 
				info@sarplataygemas.com
				www.oscaddons.com
*********************************************************************************************************************
Compatibility:
OsC 2.3.4.1. CE Frozen, 2.3.4.(1.) Bootstrap Community Editions GOLD and EDGE
PHP: 5.3-7.2
*********************************************************************************************************************

What does this contribution do?

    Recently Viewed Products(sales optimized) allows a guest to see what products they have viewed and then easily order those products.

    Features include:

        An optional box in either side column with each product's image, name, and price, plus a button linked to a page of recently viewed products. The number of products shown and each of the elements can be controlled from the Box Module Configuration.
        An optional module in the header area with each product's image, name and price, plus a button linked to a page of recently viewed products. The number of products shown, the length of the name, and each of the elements can be controlled from the Content Module Configuration.
        An optional module at the bottom of the product page with each product's image, name, description, and price, plus a button linked to a page of recently viewed products. The number of products shown, the length of the description, and each of the elements can be controlled from the Content Module Configuration.
        An optional module at the bottom of the home page (index top) with each product's image, name, description, and price, plus a button linked to a page of recently viewed products. The number of products shown, the length of the description, and each of the elements can be controlled from the Content Module Configuration.
        An optional module at the bottom of the Categories page (index nested) with each product's image, name, description, and price, plus a button linked to a page of recently viewed products. The number of products shown, the length of the description, and each of the elements can be controlled from the Content Module Configuration.
        An optional module on the shopping cart page with a continue shopping button which links to the last visited page, plus a drop down menu a list of recently viewed products. The number of products shown can be controlled from the Content Module Configuration.
        An optional module on the shopping cart page with each product's image, name, description, and price, plus a button linked to a page of recently viewed products. The number of products shown, the length of the description, and each of the elements can be controlled from the Content Module Configuration.
        A page with each product's image, name, description, price, and a Buy Now button.

*********************************************************************************************************************
How does this contribution work?

    Every time a product is viewed, the product ID is stored in a session variable. This variable is queried and the information retrieved from the database for each product.
*********************************************************************************************************************
How do I install this contribution?

    Backup your site PHP files and database. Do this before you even read the rest of these instructions. 
*********************************************************************************************************************

STEP 1 - Upload all new files from the "uploads" folder keeping the same structure.
				 No existing file will be overwritten.

[catalog/]includes/languages/english/modules/boxes/bm_recently_viewed.php
[catalog/]includes/languages/english/modules/content/header/cm_header_recently_viewed.php
[catalog/]includes/languages/english/modules/content/index/cm_i_recently_viewed.php
[catalog/]includes/languages/english/modules/content/index_nested/cm_in_recently_viewed.php
[catalog/]includes/languages/english/modules/content/product_info/cm_pi_recently_viewed.php
[catalog/]includes/languages/english/modules/content/shopping_cart/cm_sc_continue_recently_viewed.php
[catalog/]includes/languages/english/modules/content/shopping_cart/cm_sc_recently_viewed.php
[catalog/]includes/languages/english/modules/header_tags/ht_recently_viewed.php
[catalog/]includes/languages/english/recently_viewed.php
[catalog/]includes/languages/espanol/modules/boxes/bm_recently_viewed.php
[catalog/]includes/languages/espanol/modules/content/header/cm_header_recently_viewed.php
[catalog/]includes/languages/espanol/modules/content/index/cm_i_recently_viewed.php
[catalog/]includes/languages/espanol/modules/content/index_nested/cm_in_recently_viewed.php
[catalog/]includes/languages/espanol/modules/content/product_info/cm_pi_recently_viewed.php
[catalog/]includes/languages/espanol/modules/content/shopping_cart/cm_sc_continue_recently_viewed.php
[catalog/]includes/languages/espanol/modules/content/shopping_cart/cm_sc_recently_viewed.php
[catalog/]includes/languages/espanol/modules/header_tags/ht_recently_viewed.php
[catalog/]includes/languages/espanol/recently_viewed.php
[catalog/]includes/languages/german/modules/boxes/bm_recently_viewed.php
[catalog/]includes/languages/german/modules/content/header/cm_header_recently_viewed.php
[catalog/]includes/languages/german/modules/content/index/cm_i_recently_viewed.php
[catalog/]includes/languages/german/modules/content/index_nested/cm_in_recently_viewed.php
[catalog/]includes/languages/german/modules/content/product_info/cm_pi_recently_viewed.php
[catalog/]includes/languages/german/modules/content/shopping_cart/cm_sc_continue_recently_viewed.php
[catalog/]includes/languages/german/modules/content/shopping_cart/cm_sc_recently_viewed.php
[catalog/]includes/languages/german/modules/header_tags/ht_recently_viewed.php
[catalog/]includes/languages/german/recently_viewed.php
[catalog/]includes/modules/boxes/templates/recently_viewed.php
[catalog/]includes/modules/boxes/bm_recently_viewed.php
[catalog/]includes/modules/content/header/templates/recently_viewed.php
[catalog/]includes/modules/content/header/cm_header_recently_viewed.php
[catalog/]includes/modules/content/index/templates/recently_viewed.php
[catalog/]includes/modules/content/index/cm_i_recently_viewed.php
[catalog/]includes/modules/content/index_nested/templates/category_recently_viewed.php
[catalog/]includes/modules/content/index_nested/cm_in_recently_viewed.php
[catalog/]includes/modules/content/product_info/templates/recently_viewed.php
[catalog/]includes/modules/content/product_info/cm_pi_recently_viewed.php
[catalog/]includes/modules/content/shopping_cart/templates/recently_viewed_continue.php
[catalog/]includes/modules/content/shopping_cart/cm_sc_continue_recently_viewed.php
[catalog/]includes/modules/content/shopping_cart/templates/recently_viewed.php
[catalog/]includes/modules/content/shopping_cart/cm_sc_recently_viewed.php
[catalog/]includes/modules/header_tags/ht_recently_viewed.php
[catalog/]recently_viewed.php


******************************************************************************************************************
The following modifications to store files depend on your 2.3.4.(1.) BS version.
If you are using 2.3.4.1. CE Frozen, you do not need to apply any of the following editions.
Careful read ALL indications to know if you need to apply changes or not
******************************************************************************************************************

STEP 2 - Index - Home page:

If your 2.3.4. BS EDGE version is newer than 12th of May 2016, your index page is already modularized and you do not need to apply any modifications to index.php

If your 2.3.4 BS EDGE version is older or GOLD, appply the following changes to index.php:

In: [catalog/]index.php

a. Find around line 92:

<?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?>

Add below:
  
  <div class="row">
    <?php echo $oscTemplate->getContent('index_nested'); ?>
  </div>


b. Find around line 250:

    include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);
?>

</div>

Add below:
  
  <div class="row">
    <?php echo $oscTemplate->getContent('index_nested'); ?>
  </div>

c. Find around line 270:

  <div class="alert alert-info">
    <?php echo tep_customer_greeting(); ?>
  </div>

Add below:
  
  <div class="row">
    <?php echo $oscTemplate->getContent('index'); ?>
  </div>


*********************************************************************************************************************
STEP 3 - Product Info Page:

If you do not have yet included the content module call in your product_info.php (Before Bootstrap Gold release versions):
Edit the following file
In: [catalog/]product_info.php

Find:
  <div class="buttonSet row">
    <div class="col-xs-6"><?php echo tep_draw_button(IMAGE_BUTTON_REVIEWS . (($reviews['count'] > 0) ? ' (' . $reviews['count'] . ')' : ''), 'fa fa-commenting', tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params())); ?></div>
    <div class="col-xs-6 text-right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'fa fa-shopping-cart', null, 'primary', null, 'btn-success'); ?></div>
  </div>

Add below:
  
  <div class="row">
    <?php echo $oscTemplate->getContent('product_info'); ?>
  </div>
    
*********************************************************************************************************************
STEP 4 - Shopping Cart Page

If you do not have yet included the content module call in your shopping_cart.php (Before 2.3.4.1. CE Frozen versions):
Edit the following file

Install the Modular Shopping Cart BS Add-On:
http://addons.oscommerce.com/info/9466

Or:
http://oscaddons.com/en/free-add-ons/modular-shopping-cart-p-37.html

ALTERNATIVE:
If you wouldn't like to add the complete modular shopping cart:
Edit the following file:

In: [catalog/]shopping_cart.php

</form>

<?php
  } else {
?>

Replace with:

</form>

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

<?php
  } else {
?>
  
    
*********************************************************************************************************************
STEP 5 - currency class

If your 2.3.4. BS EDGE version is newer than 2th of June 2016, your currency class should  be up to date and you do not need to apply any modifications to includes/classes/currencies.php

If your 2.3.4 BS EDGE version is older or GOLD, appply the following changes to includes/classes/currencies.php:

Edit the following file:

In: [catalog/]includes/classes/currencies.php
  
Find:

    function display_price($products_price, $products_tax, $quantity = 1) {
      return $this->format($this->calculate_price($products_price, $products_tax, $quantity));
    }

    add just below (make sure you add it before the last bracket "}" which closes the class):
    
    function format_raw($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') {
      global $currency;

      if (empty($currency_type)) $currency_type = $currency;

      if ($calculate_currency_value == true) {
        $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
        $format_string = number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], '.', '');
      } else {
        $format_string = number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], '.', '');
      }

      return $format_string;
    }

    function display_raw($products_price, $products_tax, $quantity = 1) {
      return $this->format_raw($this->calculate_price($products_price, $products_tax, $quantity));
    }    

*********************************************************************************************************************
STEP 6 - font awesome icons

If your 2.3.4. BS version is Gold or EDGE, you should have already the font awesome icons included.

You can check any way and update to the latest version on july 2016:

Edit the following file:

In: [catalog/]includes/template.top.php
  
Find:

<!-- font awesome -->

Update the next line to:

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">

*********************************************************************************************************************
How to Use this Contribution
*********************************************************************************************************************

After installing the files, point your browser in your Admin area to:

A.  Required Module!
		Admin > Modules > Header Tags:
    Install Header Tag 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.

B.  Optional Module
		Admin > Modules > Boxes:
    Install Box Module: Recently Viewed
Shows the Recently Viewed box on the left or right column

C.  Optional Module
		Admin > Modules > Content:
    Install Content Module: Recently Viewed (index)
Shows the Recently Viewed module on the home page

D.  Optional Module
		Admin > Modules > Content:
    Install Content Module: Recently Viewed (index_nested)
Shows the Recently Viewed module on the category level

E.  Optional Module
		Admin > Modules > Content:
    Install Content Module: Recently Viewed (product_info)
Shows the Recently Viewed module on the product page

F.  Optional Module
		Admin > Modules > Content:
    Install Content Module: Continue shopping & Recently menu (shopping_cart)
Shows the Continue shopping button & Recently viewed drop down menu on the shopping cart page

G.  Optional Module
		Admin > Modules > Content:
    Install Content Module: Recently Viewed (shopping_cart)
Shows the Recently Viewed module on the shopping cart page

H.  Optional Module
		Admin > Modules > Content:
    Install Content Module: Recently Viewed (header)
Shows the Recently Viewed module in the header area

*********************************************************************************************************************
IMPORTANT:  If you are using Header Tag Grid List Javascript Module, include the Page: recently_viewed.php
*********************************************************************************************************************
IMPORTANT:  If you are using Equal Height Mode in the Recently Viewed product info module, 
						make sure to include the product_info.php in the Equal Height Divs (jQuery) Header Tag module.
*********************************************************************************************************************
Troubleshooting: If you modified includes/modules/product_listing.php  by another add-on or customization, 
you need to apply the related changes you did in index.php also to recently_viewed.php.
*********************************************************************************************************************

*********************************************************************************************************************
DEFAULT SETTINGS FOR THE MODULES
*********************************************************************************************************************

A.  Required for all other modules to work!
		Admin > Modules > Header Tags:
    Install Module: Recently Viewed

Default Settings (No changes needed):

Enable Recently Viewed Module
True

Pages
product_info.php

Sort Order
0

*********************************************************************************************************************
      
B.  Optional Module
		Admin > Modules > Boxes:
    Install Module: Recently Viewed

Default Settings:
    
Enable Recently Viewed Module
True

Content Placement
Right Column

Sort Order
5100

Number of products
5

Show images
True

Show name
True

Name length
23

Show description in box
False

Maximum word length
40

Description length
250

Show price
True

Show button
True

Show the current product
False


*********************************************************************************************************************   
C.  Optional Module
		Admin > Modules > Content:
    Install Module: Recently Viewed (index)

Default Settings:

Enable Recently Viewed Module
True

Content Width
12

Product Width: 
3 (will show products in 12/3=4 columns)

Sort Order
1200

Number of Products
6

Show the product image
True

Show the product name
True

Maximum word length
40

Maximum of characters
32

Show the product description
False

Maximum description length
250

Show the product price
True

Show the VIEW and BUY buttons
True

Show the product MORE button
True

Product order
Newest

Height mode
Equal Height

Fixed height value
16

*********************************************************************************************************************   
D.  Optional Module
		Admin > Modules > Content:
    Install Module: Recently Viewed (index_nested)

Default Settings:

Enable Recently Viewed Module
True

Content Width
12

Product Width: 
3 (will show products in 12/3=4 columns)

Sort Order
1200

Number of Products
6

Show the product image
True

Show the product name
True

Maximum word length
40

Maximum of characters
32

Show the product description
False

Maximum description length
250

Show the product price
True

Show the VIEW and BUY buttons
True

Show the product MORE button
True

Product order
Newest

Height mode
Equal Height

Fixed height value
16

*********************************************************************************************************************
E.  Optional Module
		Admin > Modules > Content:
    Install Module: Recently Viewed (product_info)
   
Default Settings:

Enable Recently Viewed Module
True

Content Width
12

Product Width: 
3 (will show products in 12/3=4 columns)

Sort Order
1200

Number of Products
6

Show the product image
True

Show the product name
True

Maximum word length
40

Maximum of characters
32

Show the product description
False

Maximum description length
250

Show the product price
True

Show the product MORE button
True

Show the current product
False

Product order
Newest

Height mode
Equal Height

Fixed height value
16

*********************************************************************************************************************
F.  Optional Module
		Admin > Modules > Content:
    Install Module: Continue shopping & Recently menu (shopping_cart)
   
Default Settings:

Enable Continue shopping & Recently menu Module
True

Content Width
12

Sort Order
150

Number of Products
6

Show Continue Shopping Button
True

Show the product MORE button
True

Show the shopping cart products
False

Product order
Newest

*********************************************************************************************************************
G.  Optional Module
		Admin > Modules > Content:
    Install Module: Recently Viewed (shopping_cart)
   
Default Settings:

Enable Recently Viewed Module
True

Content Width
12

Product Width: 
3 (will show products in 12/3=4 columns)

Sort Order
1200

Number of Products
6

Show the product image
True

Show the product name
True

Maximum word length
40

Maximum of characters
32

Show the product description
False

Maximum description length
250

Show the product price
True

Show the product MORE button
True

Show the shopping cart products
False

Product order
Newest

Height mode
Equal Height

Fixed height value
16

*********************************************************************************************************************
H.  Optional Module
		Admin > Modules > Content:
    Install Module: Recently Viewed (header)
   
Default Settings:

Enable Recently Header menu
True

Content Width
12

Sort Order
0

Number of Products
6

Show the product image
True

Show the product name
True

Maximum word length
40

Maximum of characters
32

Show the product price
True

Show the product MORE button
True

Show the actual products
False

Product order
Newest
  
*********************************************************************************************************************
  Support

    If you still have questions after reading these instructions, go to the Recently Viewed Products(sales optimized) forum and search first. If you still can't find an answer, ask.
    
    http://forums.oscommerce.com/topic/282340-contribution-recently-viewed-productssales-optimized/
    Note: I will only support this version for 2.3.4 Bootstrap, @raiwa
    
    The original author's contribution button has been left here as a courtesy.

Credits and History

    This contribution contains code derived from many contributions including - recently viewed, new products, sitemap & wishlist (the html code for this page).

        1.0 Original version by b00
        2.0 Updates and additional features by Kymation

