You are here:  » products page


products page

Submitted by george-p on Thu, 2013-05-09 01:22 in

Hello David again :)

i have many products with same name like this one {link saved}

how i can show here http://i.imgur.com/TH8Z6yJ.png lowest price mercant only once ?

also because i have many products with same name {link saved} , at products price list i added description and image
but in cases there is only one products price like here {link saved} i dont want to show description and image
how i can do this ?

thanks

Submitted by support on Thu, 2013-05-09 09:16

Hello George,

To ensure that each merchant is featured only once in the lowest price merchants list, look for the following code at line 26 in html/product.php:

<?php foreach($product["products"] as $priceProduct): ?>

....and REPLACE with:

$cheapestMerchants = array();
<?php foreach($product["products"] as $priceProduct): ?>
<?php
if (in_array($priceProduct["merchant"],$cheapestMerchants)) continue;
$cheapestMerchants[] = $priceProduct["merchant"];
?>

For your second question; to prevent the image / description (and cheapest price list if that's OK) from showing when there is only one merchant, you can prevent html/product.php from being included. To do this, edit products.php and look for the following code at line 116:

if (isset($product)) require("html/product.php");

...and REPLACE with:

if (isset($product) && (count($product["products"])>1)) require("html/product.php");

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Thu, 2013-05-09 13:49

thanks David

first one works

for the second one i didnt explain exactly what i want

for proudcts like this {link saved} that have only one product

i want not to show description and image at the prices table like this {link saved}

so i want a code like this "if (isset($product) && (count($product["products"])>1))" to hide the extra info i dont need

hide description

<p><?php print tapestry_substr($product["description"],110,"..."); ?></p>

and image

<td class="priceimages"><a href='<?php print htmlspecialchars($product["image_url"]); ?>' class='highslide' onclick='return hs.expand(this)'><img width='80' src='<?php print htmlspecialchars($product["image_url"]); ?>' title='Μεγέθυνση' /></a>
<div class="highslide-caption">
<a href='<?php print tapestry_buyURL($product); ?>' target="_blank">
<?php print $product["original_name"]; ?>
</a>
</div>
</td>

thanks

Submitted by support on Thu, 2013-05-09 14:11

Hi George,

Ah I see - for description; use:

<?php if (count($prices["products"])>1): ?>
<p><?php print tapestry_substr($product["description"],110,"..."); ?></p>
<?php endif; ?>

...and for image, similarly:

<?php if (count($prices["products"])>1): ?>
<td class="priceimages"><a href='<?php print htmlspecialchars($product["image_url"]); ?>' class='highslide' onclick='return hs.expand(this)'><img width='80' src='<?php print htmlspecialchars($product["image_url"]); ?>' title='Μεγέθυνση' /></a>
<?php endif; ?>
<div class="highslide-caption">
<a href='<?php print tapestry_buyURL($product); ?>' target="_blank">
<?php print $product["original_name"]; ?>
</a>
</div>
</td>

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Thu, 2013-05-09 21:27

thanks

Submitted by Marcos on Sun, 2020-10-04 19:14

Hi David, hope you are doing well.

I tried the first code of this post in order to display only once each seller but I've got this error "Fatal error: 'continue' not in the 'loop' or 'switch' context in /home/customer/www/shopneta.com/public_html/html/product.php on line 44". Maybe it's because it only works with older versions?

Also, would it be possible to "group" all the prices displayed from the same merchant under the cheapest one? Something like this:
- Seller A: 100
- Seller B: 110
> Also from Seller B: 130
> Also from Seller B: 140
- Seller C: 120

And if this was possible, would it be possible to display it with a clickable button/ling like:
- Seller A: 100
- Seller B: 110
> There are 2 more offers from Seller B. Click here to see them
- Seller C: 120

Thank you in advance.

Best,
Marcos

Submitted by support on Mon, 2020-10-05 09:00

Hello Marcos,

Here's a complete example replacement html/prices.php to display the table as per your comments (I assume that you have made other modifications that result in multiple prices from the same merchant being in the table...)

<?php
  $prices_merchants = array();
  foreach($prices["products"] as $product)
  {
    if (!isset($prices_merchants[$product["merchant"]])) $prices_merchants[$product["merchant"]] = array();
    $prices_merchants[$product["merchant"]][] = $product;
  }
  $prices["products"] = array();
  foreach($prices_merchants as $v)
  {
    $prices["products"] = array_merge($prices["products"],$v);
  }
?>
<?php
  $prices_showVoucherCodes = FALSE;
  foreach($prices["products"] as $product)
  {
    if ($product["voucher_code"])
    {
      $prices_showVoucherCodes = TRUE;
    }
  }
?>
<div class='row pt_pr'>
  <div class='small-12 columns'>
    <table>
      <thead>
        <tr>
          <th><?php print translate("Stockist"); ?></th>
          <th class='hide-for-small-only'><?php print translate("Catalogue Product Name"); ?></th>
          <th><?php print translate("Price"); ?></th>
          <?php if ($prices_showVoucherCodes): ?>
            <th><?php print translate("Voucher Code"); ?></th>
          <?php endif; ?>
          <th>&nbsp;</th>
        </tr>
      </thead>
      <tbody>
        <?php $prices_lastMerchant ""?>
        <?php foreach($prices["products"] as $k => $product): ?>
          <?php
            $prices_first = ($prices_lastMerchant != $product["merchant"]);
            $prices_lastMerchant = $product["merchant"];
          ?>
          <tr style='background-color:#f9f9f9;<?php print ($prices_first?"":"display:none;"); ?>' class='pt_pr_m<?php print str_replace(" ","_",$product["merchant"]); ?>'>
            <?php if (file_exists("logos/".$product["merchant"].$config_logoExtension)): ?>
              <td class='pt_pr_mlogo'><a href='<?php print tapestry_buyURL($product); ?>'><img alt='<?php print htmlspecialchars($product["merchant"],ENT_QUOTES,$config_charset); ?> <?php print translate("Logo"); ?>' src='<?php print $config_baseHREF."logos/".str_replace(" ","%20",$product["merchant"]).$config_logoExtension?>' /></a></td>
            <?php else: ?>
              <td class='pt_pr_mtext'><a href='<?php print tapestry_buyURL($product); ?>'><?php print $product["merchant"]; ?></a></td>
            <?php endif; ?>
            <td class='hide-for-small-only'><?php print $product["original_name"]; ?></td>
            <td class='pt_pr_price'>
              <?php print tapestry_price($product["price"]); ?>
              <?php
                if ($prices_first && (count($prices_merchants[$product["merchant"]])>1))
                {
                  print "<span id='pt_pr_m".$k."'><br /><a onclick='$(\".pt_pr_m".str_replace(" ","_",$product["merchant"])."\").show();$(\"#pt_pr_m".$k."\").hide();'>+ ".(count($prices_merchants[$product["merchant"]])-1)." more</a></span>";
                }
              ?>
            </td>
            <?php if ($prices_showVoucherCodes): ?>
              <td class='pt_pr_vouchercode'><?php print $product["voucher_code"]; ?></td>
            <?php endif; ?>
            <td class='pt_pr_visit'><a class='button tiny radius success' href='<?php print tapestry_buyURL($product); ?>'><?php print translate("Visit Store"); ?></a></td>
          </tr>
        <?php endforeach; ?>
      </tbody>
    </table>
  </div>
</div>

Cheers,
David.
--
PriceTapestry.com

Submitted by Marcos on Mon, 2020-10-05 19:16

That's exactly what I needed, thank you again!