You are here:  » Store Logo


Store Logo

Submitted by Tobix on Sun, 2020-11-15 08:09 in

Hi,
I wanted to include some details in the search such as:
{link saved}
such as the logo or the writing of the store How can I do?

Submitted by support on Mon, 2020-11-16 09:32

Hi Tobix,

Search results are generated from a summary query in order to get the merchant count and minPrice so there may be multiple merchants that apply to the result however if there is only 1 it is no problem to show the merchant logo. For example, to add the logo below the price, edit the plugin file pto_search.php and look for the following code at line 39:

  $pto_searchSelect = "SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice";

...and REPLACE with:

  $pto_searchSelect = "SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice,merchant";

And then the following code at line 584:

    $each = str_replace("%PRICE%",$pto_config_currencyHTML.$row->minPrice,$each);

...and REPLACE with:

    global $pto_config_externalPath;
    global $pto_config_logoExtension;
    global $pto_config_externalBaseHREF;
    $price = $pto_config_currencyHTML.$row->minPrice;
    if ($row->numMerchants == 1)
    {
      if (file_exists($pto_config_externalPath."logos/".$row->merchant.$pto_config_logoExtension))
      {
        $merchant = "<img border='0' src='".$pto_config_externalBaseHREF."logos/".str_replace(" ","%20",$row->merchant).$pto_config_logoExtension."' />";
      }
      else
      {
        $merchant = $row->merchant;
      }
      $price .= "<br />".$merchant;
    }
    $each = str_replace("%PRICE%",$price,$each);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Tobix on Mon, 2020-11-16 18:23

Thanks,
I would like it to appear even if there are more than one is it possible? Then is it also possible to decide where to insert it? It puts it under the price but in a messy, unaligned way.

Submitted by support on Tue, 2020-11-17 08:17

Hello Tobix,

Sure - first revert the modification above so that pto_search.php is as before. Then to re-query the results to get the merchant with the lowest price, look for the following code at line 531:

  $html .= $pto_html_search_before;

...and REPLACE with:

  $html .= $pto_html_search_before;
  global $pto_config_databaseTablePrefix;
  $ins = array();
  foreach($pto_searchResults as $row)
  {
    $ins[] = "'".esc_sql($row->name)."'";
  }
  $sql = "SELECT name,merchant FROM `".$pto_config_databaseTablePrefix."products` WHERE name IN (".implode(",",$ins).") ORDER BY name,price";
  $wpdb->query($sql);
  $cheapestMerchants = array();
  foreach($wpdb->last_result as $row)
  {
    if (!isset($cheapestMerchants[$row->name]))
    {
      $cheapestMerchants[$row->name] = $row->merchant;
    }
  }

And then the following code at (now) line 600:

    $each = str_replace("%PRICE%",$pto_config_currencyHTML.$row->minPrice,$each);

...and REPLACE with:

    global $pto_q;
    global $pto_config_externalPath;
    global $pto_config_logoExtension;
    global $pto_config_externalBaseHREF;
    if (file_exists($pto_config_externalPath."logos/".$cheapestMerchants[$row->name].$pto_config_logoExtension))
    {
      $merchant = "<img border='0' src='".$pto_config_externalBaseHREF."logos/".str_replace(" ","%20",$cheapestMerchants[$row->name]).$pto_config_logoExtension."' />";
    }
    else
    {
      $merchant = $cheapestMerchants[$row->name];
    }
    $each = str_replace("%MERCHANT%",$merchant,$each);
    $each = str_replace("%PRICE%",$pto_config_currencyHTML.$row->minPrice,$each);

And then for control over where the logo or merchant name appears, edit the Prices / Each template (wp-admin > Settings > PriceTapestry.org0 and add the placeholder;

%MERCHANT%

...as required.

Cheers,
David.
--
PriceTapestry.com

Submitted by Tobix on Wed, 2020-11-18 11:58

Perfect! Good Work!