You are here:  » products page problem


products page problem

Submitted by george-p on Fri, 2013-06-14 18:39 in

Hello David

at products page for products that are available from more than one merchants, shows the lowest price button once for each merchant
example here {link saved} {link saved} , this product is available from 2 merchants and shows lowest price button twice

i want the lower pcice button to be only one like here {link saved}

this is the code that i have at product.php

<td>
  <?php $cheapestMerchants = array(); ?>
  <?php foreach($product["products"] as $priceProduct): ?>
  <?php
  if (in_array($priceProduct["merchant"],$cheapestMerchants)) continue;
  $cheapestMerchants[] = $priceProduct["merchant"];
  ?>
  <?php if ($priceProduct["price"] == $mainProduct["price"]): ?>
    <a href='<?php print tapestry_buyURL($priceProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$priceProduct["merchant"]); ?> target="_blank" class="buyurl"><strong><?php print translate("Buy Product"); ?></strong></a>
    <?php if ($priceProduct["voucher_code"]) print " ".translate("using voucher code")." <strong>".$priceProduct["voucher_code"]."</strong>"?>
    <br />
  <?php else: ?>
  <?php break; ?>
  <?php endif; ?>
  <?php endforeach; ?>
  <?php if (isset($mainProduct["extraHTML"])) print $mainProduct["extraHTML"]; ?>
</td>

thanks

Submitted by support on Sat, 2013-06-15 08:18

Hi George,

To display the cheapest price link / button for on the first merchant with the same cheapest price, simply insert a break; statement as below:

<td>
  <?php $cheapestMerchants = array(); ?>
  <?php foreach($product["products"] as $priceProduct): ?>
  <?php
  if (in_array($priceProduct["merchant"],$cheapestMerchants)) continue;
  $cheapestMerchants[] = $priceProduct["merchant"];
  ?>
  <?php if ($priceProduct["price"] == $mainProduct["price"]): ?>
    <a href='<?php print tapestry_buyURL($priceProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$priceProduct["merchant"]); ?> target="_blank" class="buyurl"><strong><?php print translate("Buy Product"); ?></strong></a>
    <?php if ($priceProduct["voucher_code"]) print " ".translate("using voucher code")." <strong>".$priceProduct["voucher_code"]."</strong>"?>
    <br />
    <?php break; ?>
  <?php else: ?>
  <?php break; ?>
  <?php endif; ?>
  <?php endforeach; ?>
  <?php if (isset($mainProduct["extraHTML"])) print $mainProduct["extraHTML"]; ?>
</td>

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Sat, 2013-06-22 19:10

thanks, works great!