You are here:  » Product page button


Product page button

Submitted by wesse249 on Sun, 2015-12-13 19:43 in

Hello David,

I have this button on my productpage under the description.

  foreach($product["products"] as $p)
  {
    if ($p["price"] == $product_main["price"])
    {
      $html = "<a class='button tiny radius success' href='".tapestry_buyURL($p)."'>Meer informatie over dit product!</a>";
      if ($p["voucher_code"])
      {
        $html .= " (".translate("using voucher code")." <span class='pt_pr_vouchercode'>".$p["voucher_code"]."</span>)";
      }
      $product_bestPriceMerchants[] = $html;
    }
  }

When there are more then two merchant offering this product i get two buttons.

What do i need to change?

Thanks Jan Roel

Submitted by support on Mon, 2015-12-14 12:20

Hello Jan,

If you only want to display the code generated within the loop for the first (cheapest) merchant you can add a break; - have a go with;

  foreach($product["products"] as $p)
  {
    if ($p["price"] == $product_main["price"])
    {
      $html = "<a class='button tiny radius success' href='".tapestry_buyURL($p)."'>Meer informatie over dit product!</a>";
      if ($p["voucher_code"])
      {
        $html .= " (".translate("using voucher code")." <span class='pt_pr_vouchercode'>".$p["voucher_code"]."</span>)";
      }
      $product_bestPriceMerchants[] = $html;
    }
    break;
  }

Cheers,
David.
--
PriceTapestry.com