You are here:  » Top Viewed Products


Top Viewed Products

Submitted by Rocket32 on Wed, 2014-08-20 00:47 in

I would like to know where to place code from http://www.pricetapestry.com/node/4694 within the new wordpress plugin to record top views on products.

Also is there a shortcode I can use to put top ten views in the sidebar of the wordpress theme possibly with pics?

Submitted by support on Wed, 2014-08-20 05:51

Hello Roy,

If you look for the following code at line 382 in pto_product.php:

  $html_product = $pto_html_product;

...and REPLACE with:

  $sql = "UPDATE `".$pto_config_databaseTablePrefix."products` SET views = views + 1 WHERE normalised_name = '".$wpdb->escape($pto_product)."'";
  database_queryModify($sql,$result);
  $html_product = $pto_html_product;

The easiest way to make a widget to show top 10 viewed products is to create a special Featured Products "section" name e.g. "top10". To do this, look for the following code at line 25 in pto_featured.php:

  if ($section)

...and REPLACE with:

  if ($section == "top10")
  {
    $sql = "SELECT DISTINCT(name),1 AS sequence FROM `".$pto_config_databaseTablePrefix."products` ORDER BY views DESC LIMIT 10";
  }
  elseif ($section)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com