Hi David
I hope you are well!!!
I'm currently working on a fresh build of my site using the versions advancements from the last release. The forum is a great place to help me in this process as you know I have hundreds of edits on my script so keeping the forum online is great!!
One issue I have come against is that I have feeds from another price comparison site to help in the event I maybe have not the cheapest price on a product, however sometimes their price is matching my lowest price (usually from the same merchant). Is there a way that the products.php can hide this merchant in the event the price is equal to my lowest price (only on feeds, not including api merchants)
Your assistance in this would be greatly appreciated
Kind regards
Phil
Thanks David
Works Great! out of interest in the future if i need to do the same again with a second merchant what would i change on the code?
Hi Phil,
Sure - here's an alternative version using an array of merchant names to hide if any of them are the same lowest price as a datafeed merchant...
$hideMerchants = array("Merchant Name 1","Merchant Name 2");
foreach($product["products"] as $p)
{
if (!in_array($p["merchant"],$hideMerchants))
{
$lowestDatafeedPrice = $p["price"];
}
}
if (isset($lowestDatafeedPrice))
{
$newProducts = array();
foreach($product["products"] as $p)
{
if (in_array($p["merchant"],$hideMerchants) && ($p["price"]==$lowestDatafeedPrice))
{
continue;
}
$newProducts[] = $p;
}
$product["products"] = $newProducts;
$prices["products"] = $newProducts;
}
Cheers,
David.
--
PriceTapestry.com
Hi Phil,
Sure - have a go with the following block of code at the very top of html/product.php - immediately after the opening PHP tag:
$hide = "Merchant Name";
if ((count($product["products"])>1) && ($product["products"][0]["price"]==$product["products"][1]["price"]))
{
if (($product["products"][0]["merchant"] == $hide) || ($product["products"][1]["merchant"] == $hide))
{
$newProducts = array();
foreach($product["products"] as $p)
{
if ($p["merchant"] <> $hide) $newProducts[] = $p;
}
$product["products"] = $newProducts;
$prices["products"] = $newProducts;
}
}
Edit "Merchant Name" (the value of $hide) as required to remove that merchant from the results if it is either the first or second result, and the same price as the other first or second result...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com