You are here:  » Merchant Information

Active Forum Topics


Merchant Information

Submitted by babyuniverse on Sat, 2021-07-10 07:15 in

Hi David,

Hope you have been well!!

I am refreshing some of my sites and would like your help woith the following.

Merchant Information.
I currently use an existing modification so when I add merchant.html into a folder it displays on the search results page. This is hard to keep up to date.

Is there a way to use the database to add a merchant description (similar to how the merchant_logo.php works). I select an existing merchant from admin and then add description or html, which can be updated as required.

I could then display this on the merchant search results page and add css etc to it.

I hope this makes sense

Thanks
Richard

Submitted by support on Mon, 2021-07-12 08:16

Hi Richard,

Check out this comment which I think is exactly what you're after...

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Fri, 2021-07-16 10:42

Thanks Mate, That's perfect.

1 question, I currently have the following in search.php

{code saved}

To create the META description for each merchant. (im using generic text).

How would I add the new merchant_info description to that?

Submitted by support on Fri, 2021-07-16 11:48

Hi,

Add the following immediately after that line to pull in the merchant description...

    if ($parts[0]=="merchant")
    {
      $sql = "SELECT info FROM `".$config_databaseTablePrefix."merchant_info`
        WHERE name = '".database_safe($parts[1])."'";
      if (database_querySelect($sql,$rows))
      {
        $header["meta"]["description"] .= " ".$rows[0]["info"];
      }
    }

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Sat, 2021-07-17 04:27

That's awesome.

Can I use this code on each individual product? After the current description.

$sql = "SELECT info FROM `".$config_databaseTablePrefix."merchant_info`
WHERE name = '".database_safe($parts[1])."'";
if (database_querySelect($sql,$rows))
{
print $rows[0]["info"];
}

Submitted by support on Mon, 2021-07-19 07:35

Hi,

Bear in mind that the product page is product rather than merchant specific however with almost identical code you could pull in the merchant description of the cheapest merchant by editing html/product.php and look for the following cdoe at line 58:

      <p><?php print $product_main["description"]; ?></p>

...and REPLACE with:

      <p><?php print $product_main["description"]; ?></p>
      <?php
        $sql = "SELECT info FROM `".$config_databaseTablePrefix."merchant_info`
        WHERE name = '".database_safe($product_main["merchant"])."'";
        if (database_querySelect($sql,$rows))
        {
          print "<p>".$rows[0]["info"]."</p>";
        }
      ?>

Alternatively, you could pull in the merchant_info for every merchant that sells the product and include it in the price comparison table, for example below the original product name by editing html/prices.php and looking for the following code at line 57:

            <td class='hide-for-small-only'><?php print $product["original_name"]; ?></td>

...and REPLACE with:

            <td class='hide-for-small-only'>
              <?php print $product["original_name"]; ?>
              <?php
                $sql = "SELECT info FROM `".$config_databaseTablePrefix."merchant_info`
                WHERE name = '".database_safe($product["merchant"])."'";
                if (database_querySelect($sql,$rows))
                {
                  print "<p>".$rows[0]["info"]."</p>";
                }
              ?>
            </td>

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Sun, 2021-07-25 04:46

Hi David,

That worked perfectly. I have now implemented https://www.pricetapestry.com/node/6150#comment-25040

I have added the following code to searchresults.php

<?php
  
if (($page==1) && isset($parts[1]) && ($parts[0]=="merchant"))
  {
    
$sql "SELECT * FROM `".$config_databaseTablePrefix."merchant_info` WHERE name='".database_safe($parts[1])."'";
    if (
database_querySelect($sql,$rows))
    {
      print 
"<div class='row'><div class='small-12' columns style = 'padding: 0px; font-size:18px;'><p class='merchant_info'>".$rows[0]["info"]."</p></div></div>";
    }
  }
 
?>

This is working fine, however I would now like to bring in the merchant logo for this.

Can you help?

Thanks
Richard

Submitted by support on Mon, 2021-07-26 07:22

Hi Richard,

Sure - have a go with something like;

<?php
  
if (($page==1) && isset($parts[1]) && ($parts[0]=="merchant"))
  {
    
$sql "SELECT * FROM `".$config_databaseTablePrefix."merchant_info` WHERE name='".database_safe($parts[1])."'";
    if (
database_querySelect($sql,$rows))
    {
      print 
"<div class='row'><div class='small-12 columns' style='padding:0px;font-size:18px;'>";
      print 
"<p class='merchant_info'>";
      if (
file_exists("logos/".$parts[1].$config_logoExtension))
      {
        print 
"<img src='".$config_baseHREF."logos/".str_replace(" ","%20",$parts[1].$config_logoExtension)."' />";
      }
      print 
$rows[0]["info"];
      print 
"</p>";
      print 
"</div></div>";
    }
  }
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Mon, 2021-07-26 08:55

Thanks Mate.

The logo is coming back as https://example.com/logos/.img
Doesn't seem to be getting the merchant name/

Submitted by support on Mon, 2021-07-26 10:08

Sorry about that had $product["merchant"] instead of $parts[1]. Corrected above...

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Mon, 2021-07-26 12:26

That seems to break it.

Submitted by support on Mon, 2021-07-26 13:07

Ooops - deleted a closing bracket making the last mod - should be OK now...!

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Fri, 2021-08-06 09:28

Thanks So much for your help

I have replicated https://www.pricetapestry.com/node/6150#comment-25040 with merchant_title
so I can set a META title for each merchant individually. (i have also seperately created merchant_shipping and merchant_info)

I would now like to set the TITLE of the meta to be title from merchant_title or else default back to a common title.

if ($parts[0]=="merchant")
{
  $sql = "SELECT title FROM `".$config_databaseTablePrefix."merchant_title`
  WHERE name = '".database_safe($parts[1])."'";
  if (database_querySelect($sql,$rows))
  {
    $header["title"] .= " ".$rows[0]["title"];
  }
  $header["title"] = " ".$parts[1]." | Title1 | Title2";
}

This doesn't seem to be working. Any ideas?

Also I assume I have done this the hard way, and could have combined merchant_title, merchant_shipping and merchant_info into one table?

Submitted by support on Fri, 2021-08-06 11:31

Hi Richard,

The default title needs to be inside an ELSE condition, have a go with:

if ($parts[0]=="merchant")
{
  $sql = "SELECT title FROM `".$config_databaseTablePrefix."merchant_title` WHERE name = '".database_safe($parts[1])."'";
  if (database_querySelect($sql,$rows))
  {
    $header["title"] .= " ".$rows[0]["title"];
  }
  else
  {
    $header["title"] = " ".$parts[1]." | Title1 | Title2";
  }
}

Yes - a single table could be used and would save multiple database calls on the page...

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Sat, 2021-08-07 03:58

Thanks - Its working but adding an additional prefix

In this example the title i have added is "Merchant | Beauty Products & Cosmetics Online"

The output is merchant:MerchantName: MerchantName | Beauty Products & Cosmetics Online

Submitted by support on Sat, 2021-08-07 09:21

Hi,

The code for where there is a title in the database was using .= (append) so that should be all it is, have a go with:

if ($parts[0]=="merchant")
{
  $sql = "SELECT title FROM `".$config_databaseTablePrefix."merchant_title` WHERE name = '".database_safe($parts[1])."'";
  if (database_querySelect($sql,$rows))
  {
    $header["title"] = " ".$rows[0]["title"];
  }
  else
  {
    $header["title"] = " ".$parts[1]." | Title1 | Title2";
  }
}

Cheers,
David.
--
PriceTapestry.com