You are here:  » Show price comparison table in listing results..

Support Forum



Show price comparison table in listing results..

Submitted by quokka on Wed, 2011-09-14 21:10 in

Hi,

Just purchased PT today.
Thanks for the great script!

For our site we won't be using the product detail pages.
Instead I want to move the price comparison table from the product detail page and put it under every product in the product listing / search results page. (and if that's done I'll spice it up with some jQuery to show /hide that data on click for each product)

Didn't found a solution for this on the forums.
It's only the PHP part I wonder if it's available already on the forum.
Or maybe someone already did this and is willing to share the code (PHP code only, not the jQuery part)

Thanks in advance!
Bas

Submitted by support on Thu, 2011-09-15 06:44

Hello Bas,

In theory that's straight forward - all it would require is the comparison query performed for each search result; and then html/prices.php. Have a look at the following as a complete replacement for html/searchresults.php to get started with;

<?php
  
function cmp($a$b)
  {
    if (
$a["price"] == $b["price"])
    {
      return 
0;
    }
    return (
$a["price"] < $b["price"]) ? -1;
  }
  foreach(
$searchresults["products"] as $product)
  {
    
$sql "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE normalised_name = '".database_safe($product["normalised_name"])."'";
    
database_querySelect($sql,$rows);
    if (
$config_useVoucherCodes === 1)
    {
      
$rows tapestry_applyVoucherCodes($rows);
    }
    
usort($rows,"cmp");
    
$prices["products"] = $rows;
    print 
"<h2><a href='".tapestry_buyURL($rows[0])."'>".$rows[0]["name"]."</a></h2>";
    require(
"html/prices.php");
  }
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by quokka on Thu, 2011-09-15 09:14

Hi David,
Thank you so much!
Didn't test it yet but from here I'm sure it's very easy!
Regards,
Bas

Submitted by quokka on Thu, 2011-09-15 09:25

Sure...it works as expected.
thanks again!