You are here:  » Showing all merchants

Support Forum



Showing all merchants

Submitted by mally on Fri, 2007-12-28 19:39 in

Hello David

For most of my items I have about 4 merchants that supply it.

Would it be possible to show for each product, the prices table, but with every merchant shown. If the merchant has the item then the price is shown aswell, if not its says not stocked or something similar.

Thanks

Mally

Submitted by support on Sat, 2007-12-29 12:59

Hi,

You should be able to add the merchants not already shown with this code:

<?php
  
foreach($prices["products"] as $product)
  {
    
$in[] = "'".database_safe($product["merchant"])."'";
  }
  
$in implode(",",$in);
  
$sql "SELECT * FROM feeds WHERE merchant NOT IN (".$in.") ORDER BY merchant";
  if (
database_querySelect($sql,$feeds))
  {
    foreach(
$feeds as $feed)
    {
      if (
$config_useRewrite)
      {
        
$merchantHREF $config_baseHREF."merchant/".tapestry_hyphenate($feed["merchant"])."/";
      }
      else
      {
        
$merchantHREF $config_baseHREF."search.php?q=merchant:".urlencode($feed["merchant"]).":";
      }
      print 
"<tr>";
      print 
"<td><a href='".$merchantHREF."'>".$feed["merchant"]."</a></td>";
      print 
"<td>&nbsp;</td>";
      print 
"<td>&nbsp;</td>";
      print 
"<td>Not Stocked</td>";
      print 
"</tr>";
    }
  }
?>

Add this to html/prices.php immediately after the following line:

<?php endforeach; ?>

Hope this helps!
Cheers,
David.

Submitted by mally on Sun, 2007-12-30 22:31

Hello David

Thanks, that works however shows the merchants in a column next to each other than in rows as per my current design.

Code you have a look at the following code I currently use for displaying prices to see if it can be included in the format.

I also have the merchant logo mod included.

<h2>Subscription to <?php print $mainProduct["name"]; ?> Prices</h2>
  <div class='prices'>
  <table width='100%' cellpadding='4'>
    <tr bgcolor='#eeeeee'>
      <th width='200' align='left'><?php print translate("Stockist"); ?></th>
      <th>&nbsp;</th> <!-- blank column for merchant logo -->
      <th align='left'><?php print translate("Catalogue Product Name"); ?></th>
      <th align='left'><?php print translate("Price"); ?></th>
      <th align='left'>&nbsp;</th>
    </tr>
    <?php foreach($prices["products"] as $product): ?>
    <tr bgcolor='#ffffcc'>
      <td><a href='<?php print $product["merchantHREF"]; ?>'><?php print $product["merchant"]; ?></a></td>
      <td>
      <?php
      if (file_exists("logos/".$product["merchant"]))
      {
        print "<img src='".$config_baseHREF."logos/".$product["merchant"]."' alt='Subscribe to ".$product["name"]."' />";
      }
      else
      {
        print "&nbsp;";
      }
      ?>
      </td>
      <td><?php print $product["name"]; ?></td>
      <td><strong><?php print $config_currencyHTML.$product["price"]; ?></strong></td>
      <td align='center'><a target="_blank" href='<?php print tapestry_buyURL($product); ?>' <?php print javascript_statusBar("go to ".$product["merchant"]); ?>><?php print translate("Subscribe"); ?></a></td>
    </tr>
    <?php endforeach; ?>
  </table>
</div>

thanks

Mally

Submitted by support on Mon, 2007-12-31 12:13

Hi Mal,

Sorry about that - i'd missed out the <tr> tags which is why they were in a single row rather than inline with the existing table. I've fixed this in the code above - that should do the trick now.

Cheers,
David.

Submitted by mally on Mon, 2007-12-31 15:23

Hi David, it does, thanks.

Would you be able to show what the code would be like to include the logo's of the merchants aswell?

I've tried adding

<?php
      if (file_exists("logos/".$product["merchant"]))
      {
        print "<img src='".$config_baseHREF."logos/".$product["merchant"]."' alt='Subscribe to ".$product["name"]."' />";
      }
      else
      {
        print "&nbsp;";
      }
?>

but it doesn't work in the print" areas

Submitted by support on Mon, 2007-12-31 15:40

Hi Mal,

The code is correct apart from $product["merchant"] which in the new section should be $feed["merchant"] instead. To display the logo in its own cell within the loop the following should work:

      print "<td>";
      if (file_exists("logos/".$feed["merchant"]))
      {
        print "<img src='".$config_baseHREF."logos/".$feed["merchant"]."' alt='Subscribe to ".$feed["merchant"]."' />";
      }
      else
      {
        print "&nbsp;";
      }
      print "</td>";

If you wanted to make the image a link to the merchant search results (as the merchant name links is) then use:

      print "<td>";
      if (file_exists("logos/".$feed["merchant"]))
      {
        print "<a href='".$merchantHREF."'><img border='0' src='".$config_baseHREF."logos/".$feed["merchant"]."' alt='Subscribe to ".$feed["merchant"]."' /></a>";
      }
      else
      {
        print "&nbsp;";
      }
      print "</td>";

Cheers,
David.