You are here:  » Number of Merchants when number>1


Number of Merchants when number>1

Submitted by koen on Mon, 2014-11-10 10:36 in

Hi David,

Is it possible to show the number of merchants on the product page, next to the title. Right now I'm displaying the cheapest Merchant, but I would like to add the number of merchants that has been compared (combined with a html-anchor which clicks to the comparisson table)... So I would like to see: Product X Best Deal at Merchant Y, (Z merchants compared)

Can you help me on this one? Thanks!

Koen

Submitted by support on Mon, 2014-11-10 10:58

Hi Koen,

Sure - on the line after your current $title construction, have a go with:

if (count($pto_productResults)>1)
{
  $title .= ", (".count($pto_productResults)." merchants compared)";
}

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Tue, 2014-11-11 19:59

Thanks David!
But how do I get this into the plugin (shortcode?) :-$

Thanks!
Koen

Submitted by support on Wed, 2014-11-12 14:10

Hi Koen,

The shortcodes are invoked separately from the PriceTapestry.org virtual pages, so there's no concept of a plugin generated title / meta tags.

To add the above to the plugin generated product pages, you would edit pto.php and look for the following code at line 251:

  $title = str_replace("%PRODUCT_NAME%",htmlspecialchars($pto_productResults[0]->name),$title);

...and REPLACE with:

  $title = str_replace("%PRODUCT_NAME%",htmlspecialchars($pto_productResults[0]->name),$title);
  if (count($pto_productResults)>1)
  {
    $title .= ", (".count($pto_productResults)." merchants compared)";
  }

If you could copy the code that you have in place to display "Product X Best Deal at Merchant Y" from your shortcode, I'll show how to modify that to do the same...

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Thu, 2014-11-13 19:26

Thanks David,

This is my code for the best deal:

<p class='pto_product_price'>
<h2>Beste deal:
<strong>%PRICE%</strong> bij %PRICE_LINKS%</h2>
<em><span style="color: #ff6600;">(voor &euro; &nbsp;%DB_totalprice% bij je thuisbezorgd) </span></em>
<p>

Thanks,
Koen

Submitted by support on Fri, 2014-11-14 09:36

Hello Koen,

My apologies I mis-read your original question - no problem, it's straight forward to add a new placeholder to return the number of compared merchants.

If you edit pto_product.php and look for the following code at line 476:

$html_product = str_replace("%PRICE_LINKS%",implode(", ",$price_links),$html_product);

...and REPLACE with:

$html_product = str_replace("%PRICE_LINKS%",implode(", ",$price_links),$html_product);
$html_product = str_replace("%NUM_MERCHANTS%",count($pto_productResults),$html_product);

You can then use the placeholder %NUM_MERCHANTS% within your Product / Main template as required!

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Mon, 2014-12-08 12:56

Hi David,

Thanks for this one! Is it possible to only show the number of merchants when there are multiple merchants (NUM_MERCHANTS > 1)?
Thanks,
Koen

Submitted by support on Mon, 2014-12-08 14:02

Hi Koen,

Sure - in your modified pto_product.php where you now have this code:

  $html_product = str_replace("%NUM_MERCHANTS%",count($pto_productResults),$html_product);

...REPLACE that with:

  if (count($pto_productResults) > 1)
  {
    $html_product = str_replace("%NUM_MERCHANTS%",count($pto_productResults),$html_product);
    $html_product = str_replace("%IF_COMPARED%","",$html_product);
    $html_product = str_replace("%ENDIF_COMPARED%","",$html_product);
  }
  else
  {
    $html_product = preg_replace('/%IF_COMPARED%(.*)%ENDIF_COMPARED%/','',$html_product);
  }

And then in your template, use something like:

%IF_COMPARED%
Comparing %NUM_MERCHANTS% Prices
%ENDIF_COMPARED%

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Wed, 2014-12-17 14:56

Thanks David, great!

Submitted by koen on Fri, 2015-01-23 09:58

Hi David,

In addition to this one... Is it also possible to state the highest price (like best price, but then the higest one....) in the product section? Like a %highest_price% placeholder?
So I will got: "product available at X merchants, best price Y, highest price Z"...

Thanks in advance,
Koen

Submitted by support on Fri, 2015-01-23 10:15

Hello Koen,

Sure - in pto_product.php look for the following code at line 461:

  $html_product = str_replace("%PRICE%",$pto_config_currencyHTML.$product->price,$html_product);

...and REPLACE with:

  $html_product = str_replace("%HIGHEST_PRICE%",$pto_config_currencyHTML.$pto_productResults[count($pto_productResults)-1]->price,$html_product);
  $html_product = str_replace("%PRICE%",$pto_config_currencyHTML.$product->price,$html_product);

...and that will add support for %HIGHEST_PRICE% placeholder.

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Sun, 2015-01-25 13:10

WORKS GREAT!!

Thanks a lot.

Cheers,Koen