Forums / Addon Templates / Compare multiple products - support thread

Compare multiple products - support thread

Results 1 to 20 of 38
04 Jun 2011, 19:56
#1
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Compare multiple products - support thread

http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=1922

Do not use 1.0.1. That was modified for a specific site and most likely will not work on your site. The author has uploaded 1.0.2 which is pretty much the same as 1.0.0.

One thing I have noticed. If you do a search for a part (i.e. you have part number 3001, 43001, 3001-45, etc. and do a search for part number 3001) and it pulls up all these parts. You will see
"compare_default" under the tick box.

copy the defines from the supplied index.php file to your advanced search result.php file and upload it to your template folder.

note one thing i have noticed is that in the advanced search results screen, you cannot compare products. I have notified the author of this.
11 Jun 2011, 20:36
#2
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Re: Compare multiple products - support thread

Thanks for this fantasic mod!
I have it working except for the jQuery side.
When I check a compare box, the javascript fires (I have tested this with an alert) but the product image doesn't appear in the compare box at the top of the screen. The 'compare' button doesn't show at the top of the screen either.
However, if I refresh the page, the products do appear in the box so something behind the scenes is working.

Has anybody any ideas what is going wrong?
12 Jun 2011, 08:31
#3
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Re: Compare multiple products - support thread

Ok, I seem to have this working.
the problem is in the javascript file jscript_products_compare.js.

If I change from this...
  function compareNew(obj, action) {
    $('#compareProducts').load('ajax_compare.php', {'compare_id': obj, 'action': action});
  }


....to this.....
  function compareNew(obj, action) {
    $('#compareProducts').load('AJAX_servers/AJAX_compare_server.php', {'compare_id': obj, 'action': action},
							   function(data) {  $("#compareProducts").html(data);  }
							   );
  }


It works!
Has anybody else had this not work or is it just me?
12 Jun 2011, 19:13
#4
wilkesy avatar

wilkesy

Zen Follower

Join Date:
Jul 2004
Posts:
198
Plugin Contributions:
0

Re: Compare multiple products - support thread

hi,

Quite frustratingly i have been spending hours today trying to get this working. The ajax side of it wasnt working at all. Then, i had a moment of inspiration! I use the CEON URL re-write tool. I needed to exclude this file from being re-written and off we went! works perfectly!

Just something to keep in mind for others!
29 Jul 2011, 06:53
#5
novastar avatar

novastar

Zen Follower

Join Date:
Jul 2009
Posts:
127
Plugin Contributions:
0

Re: Compare multiple products - support thread

I have this installed on my local host and when ever I try to compare two or more products the resulting page is one that says there are no products to compare, even though I'm certain that I checked the boxes before clicking compare. any help?
13 Aug 2011, 01:43
#6
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
6

Re: Compare multiple products - support thread

willie bee:


One thing I have noticed. If you do a search for a part (i.e. you have part number 3001, 43001, 3001-45, etc. and do a search for part number 3001) and it pulls up all these parts. You will see
"compare_default" under the tick box.

copy the defines from the supplied index.php file to your advanced search result.php file and upload it to your template folder.

note one thing i have noticed is that in the advanced search results screen, you cannot compare products. I have notified the author of this.


Copy the following define statements from index.php to advanced_search_result.php
// values for compare system
  define('COMPARE_DEFAULT', 'Compare');
  define('COMPARE_REMOVE', 'remove');
  define('COMPARE_COUNT_START', 'up to ');
  define('COMPARE_COUNT_END', ' items');


copy the following code from tpl_index_product_list.php to tpl_advanced_search_result_default.php

<div id="compareResult">
  <div class="back compareText"><b><?php echo COMPARE_DEFAULT; ?></b><br /><?php echo COMPARE_COUNT_START . COMPARE_VALUE_COUNT . COMPARE_COUNT_END; ?></div>
  <div id="compareProducts">
<?php
if (!empty($_SESSION['compare'])) {
  foreach ($_SESSION['compare'] as $value) {
    $product_comp_image = $db->Execute(
        "SELECT p.products_id, p.master_categories_id, pd.products_name, p.products_image
         FROM " . TABLE_PRODUCTS . " p
         LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
         ON pd.products_id=p.products_id
         WHERE p.products_id='".$value."'");
         
    $comp_images .= '<div class="compareAdded"><br /><a href="' . zen_href_link(zen_get_info_page($product_comp_image->fields['products_id']), 'cPath=' . (zen_get_generated_category_path_rev($product_comp_image->fields['master_categories_id'])) . '&products_id=' . $product_comp_image->fields['products_id']) . '">' . $product_comp_image->fields['products_name'] . '</a><div>'.'<a onclick="javascript: compareNew('.$product_comp_image->fields['products_id'].', \'remove\')" alt="remove">'.COMPARE_REMOVE.'</a>'.'</div></div>';
  }
  echo '<div id="compareMainWrapper"><div class="compareAdded compareButton">'.'<a href="index.php?main_page=compare" alt="compare">'.'<span class="cssButton">'.COMPARE_DEFAULT.'</span></a></div>'.$comp_images.'</div>';
  echo '<br class="clearBoth" />';
}
?>
</div>
</div>


Now you will be able to add & compare products from the search result page.

Hope this helps!
13 Aug 2011, 02:09
#7
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
6

Re: Compare multiple products - support thread

Just FYI!

This also works on

products_all
products_new
featured_products

I don't use specials but sure same rules apply!
15 Sep 2011, 06:05
#8
honda_crunch avatar

honda_crunch

New Zenner

Join Date:
Jul 2011
Posts:
22
Plugin Contributions:
0

Re: Compare multiple products - support thread

Hi
Just wondered if anyone has seen the following and if there is a fix for it:

I just recently installed v1.02. Everything except a previous noted error regarding advance search worked ok. I managed to fix the advance search myself. However, looking through the cahe log I noticed the following:

PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/*****************/httpdocs/catalog/ajax_compare.php on line 29

Has anybody else noticed this?

I found a website that gave an indication that the coding may be wrong on line 29. As I'm not a programmer, I am at a loss.

Below is an extract from the web site I found:

(Invalid argument supplied for foreach() can happen if you try to do a foreach on an variable that isn't an array. Maybe it is "supposed to" be an array, maybe you thought it was an array, but sorry -- it isn't.)
03 Nov 2011, 08:13
#9
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Posts:
2,862
Plugin Contributions:
5

Re: Compare multiple products - support thread

honda-crunch:

Hi
Just wondered if anyone has seen the following and if there is a fix for it:

I just recently installed v1.02. Everything except a previous noted error regarding advance search worked ok. I managed to fix the advance search myself. However, looking through the cahe log I noticed the following:

PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/*****************/httpdocs/catalog/ajax_compare.php on line 29

Has anybody else noticed this?

I found a website that gave an indication that the coding may be wrong on line 29. As I'm not a programmer, I am at a loss.

Below is an extract from the web site I found:

(Invalid argument supplied for foreach() can happen if you try to do a foreach on an variable that isn't an array. Maybe it is "supposed to" be an array, maybe you thought it was an array, but sorry -- it isn't.)


I have the same problem. :no:
03 Nov 2011, 10:58
#10
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Re: Compare multiple products - support thread

rbarbour:

Copy the following define statements from index.php to advanced_search_result.php
// values for compare system
  define('COMPARE_DEFAULT', 'Compare');
  define('COMPARE_REMOVE', 'remove');
  define('COMPARE_COUNT_START', 'up to ');
  define('COMPARE_COUNT_END', ' items');


copy the following code from tpl_index_product_list.php to tpl_advanced_search_result_default.php

<div id="compareResult">
  <div class="back compareText"><b><?php echo COMPARE_DEFAULT; ?></b><br /><?php echo COMPARE_COUNT_START . COMPARE_VALUE_COUNT . COMPARE_COUNT_END; ?></div>
  <div id="compareProducts">
<?php
if (!empty($_SESSION['compare'])) {
  foreach ($_SESSION['compare'] as $value) {
    $product_comp_image = $db->Execute(
        "SELECT p.products_id, p.master_categories_id, pd.products_name, p.products_image
         FROM " . TABLE_PRODUCTS . " p
         LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
         ON pd.products_id=p.products_id
         WHERE p.products_id='".$value."'");
         
    $comp_images .= '<div class="compareAdded"><br /><a href="' . zen_href_link(zen_get_info_page($product_comp_image->fields['products_id']), 'cPath=' . (zen_get_generated_category_path_rev($product_comp_image->fields['master_categories_id'])) . '&products_id=' . $product_comp_image->fields['products_id']) . '">' . $product_comp_image->fields['products_name'] . '</a><div>'.'<a onclick="javascript: compareNew('.$product_comp_image->fields['products_id'].', \'remove\')" alt="remove">'.COMPARE_REMOVE.'</a>'.'</div></div>';
  }
  echo '<div id="compareMainWrapper"><div class="compareAdded compareButton">'.'<a href="index.php?main_page=compare" alt="compare">'.'<span class="cssButton">'.COMPARE_DEFAULT.'</span></a></div>'.$comp_images.'</div>';
  echo '<br class="clearBoth" />';
}
?>
</div>
</div>


Now you will be able to add & compare products from the search result page.

Hope this helps!


Hey! Sorry I missed your reply. Yes the first part work which makes sense. I did the code copy to the advanced tpl file but it does not work. :(
03 Nov 2011, 11:36
#11
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Re: Compare multiple products - support thread

My apologies. It does work. I just did not scroll down to the bottom where it appeared. It is dependent on where you put the code!

I put mine after

<h1 id="advSearchResultsDefaultHeading"><?php echo HEADING_TITLE; ?></h1>

Thanks again.
13 Feb 2012, 11:59
#13
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Posts:
1,326
Plugin Contributions:
0

Re: Compare multiple products - support thread

novastar:

I have this installed on my local host and when ever I try to compare two or more products the resulting page is one that says there are no products to compare, even though I'm certain that I checked the boxes before clicking compare. any help?


Just thought I'd ask whether anyone knows the reason for the above. I suspect it might be related to other mods I have installed. I've installed and reinstalled this mod but can't for the life of me see where the problem is.
13 Feb 2012, 12:14
#14
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Posts:
1,326
Plugin Contributions:
0

Re: Compare multiple products - support thread

novastar:

I have this installed on my local host and when ever I try to compare two or more products the resulting page is one that says there are no products to compare, even though I'm certain that I checked the boxes before clicking compare. any help?


Just thought - it might be because I'm running v1.50, although the original source of this query - novastar - would have been on an earlier version
14 Feb 2012, 18:50
#15
kcahir avatar

kcahir

New Zenner

Join Date:
Feb 2012
Posts:
3
Plugin Contributions:
0

Re: Compare multiple products - support thread

I have a fix for this issue but I'm unsure if it leaves open a security hole.

You only have to comment out one line within 'includes/init_includes/init_sanitize.php' at about line 34:

zen_redirect ( zen_href_link ( FILENAME_PAGE_NOT_FOUND, '', $request_type ) );
17 Feb 2012, 17:36
#16
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Posts:
1,326
Plugin Contributions:
0

Re: Compare multiple products - support thread

kcahir:

I have a fix for this issue but I'm unsure if it leaves open a security hole.

You only have to comment out one line within 'includes/init_includes/init_sanitize.php' at about line 34:

zen_redirect ( zen_href_link ( FILENAME_PAGE_NOT_FOUND, '', $request_type ) );


Thank you for your reply. I'll take a closer look.
18 Feb 2012, 10:39
#17
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Posts:
1,326
Plugin Contributions:
0

Re: Compare multiple products - support thread

Don't think I'll implement this fix - too drastic for my taste.
29 Feb 2012, 03:05
#18
novastar avatar

novastar

Zen Follower

Join Date:
Jul 2009
Posts:
127
Plugin Contributions:
0

Re: Compare multiple products - support thread

simon1066:

Just thought - it might be because I'm running v1.50, although the original source of this query - novastar - would have been on an earlier version


Yeah I'm using 1.3.9h, I installed a fresh copy of zen cart on my localhost to test this so this was the first and only mod I installed and it still didn't work. I saw that another version had been installed so I installed that on my live sight but it still has the same issue. I don't want to oversimplify a problem because I'm not an expert but it seems like a small fix, may be a bug somewhere. Any help appreciated.
29 Feb 2012, 03:07
#19
novastar avatar

novastar

Zen Follower

Join Date:
Jul 2009
Posts:
127
Plugin Contributions:
0

Re: Compare multiple products - support thread

novastar:

Yeah I'm using 1.3.9h, I installed a fresh copy of zen cart on my localhost to test this so this was the first and only mod I installed and it still didn't work. I saw that another version had been installed so I installed that on my live sight but it still has the same issue. I don't want to oversimplify a problem because I'm not an expert but it seems like a small fix, may be a bug somewhere. Any help appreciated.


"I saw that another version had been installed..." I meant that I saw that another version of the mod had been uploaded. i.e. 1.0.2.
29 Feb 2012, 23:03
#20
novastar avatar

novastar

Zen Follower

Join Date:
Jul 2009
Posts:
127
Plugin Contributions:
0

Re: Compare multiple products - support thread

I don't know the implications of commenting out that line in init_sanitize.php but I can't even find the line within the file to see if the fix might have worked. Is this because of a different version?