Support forum login

©2006-2012 IAAI Software

Contact Us Privacy Policy

Buy url directly instead of product page

Submitted by magnaromagna on Thu, 2010-06-03 01:01.

Hello David,
hope you are fine and welcome again after holidays

In my installation I prefer to remove/not use the single product page, so in search results I'd like to change from
<?php print $product["productHREF"]; ?>
to
<?php print tapestry_buyURL($priceProduct); ?>

Is it possible, right? And which modifications to do for this?

Thanks!

Submitted by support on Fri, 2010-06-04 05:23.

Hi,

This is a straight forward modification to search.php. I'll post the modifications for both distributions of Price Tapestry as I know you've been a user for a long time...

Latest Distribution (11/09A)

Look for the following code beginning at line 270:

      if ($config_useRewrite)
      {
        $searchresults["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate($product["normalised_name"]).".html";
      }
      else
      {
        $searchresults["products"][$k]["productHREF"] = $config_baseHREF."products.php?q=".urlencode($product["normalised_name"]);
      }

...and REPLACE with:

      if ($product["numMerchants"] == 1)
      {
        $searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);
      }
      elseif ($config_useRewrite)
      {
        $searchresults["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate($product["normalised_name"]).".html";
      }
      else
      {
        $searchresults["products"][$k]["productHREF"] = $config_baseHREF."products.php?q=".urlencode($product["normalised_name"]);
      }

Original Distribution (01/06A)

Look for the following code beginning at line 164:

      if ($config_useRewrite)
      {
        $searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
        if ($rewrite) $searchresults["products"][$k]["productHREF"] = "../../".$searchresults["products"][$k]["productHREF"];
      }
      else
      {
        $searchresults["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
      }

...and REPLACE with:

      if ($product["numMerchants"] == 1)
      {
        $searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);
      }
      elseif ($config_useRewrite)
      {
        $searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
        if ($rewrite) $searchresults["products"][$k]["productHREF"] = "../../".$searchresults["products"][$k]["productHREF"];
      }
      else
      {
        $searchresults["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
      }

Cheers,
David.

Submitted by magnaromagna on Fri, 2010-06-04 08:56.

Thanks David,
but I still see the link to the product instead the link to the buy url, I mean I see

$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";

but, if possible, I prefer see the buyurl of each merchant.

Submitted by support on Fri, 2010-06-04 10:28.

Hi,

The above code will only link to the merchant if there is only 1 merchant - is that the case with the searches you have tried and it is still going to the product page?

Cheers,
David.

Submitted by magnaromagna on Fri, 2010-06-04 12:17.

Hi,
no I mean search results where there are many merchants. This is an example page:

{link saved}

Thanks

Submitted by support on Fri, 2010-06-04 12:22.

Hi,

That should be how it's working - could you email me your search.php and html/searchresults.php and I'll check it out for you...

Cheers,
David.

Submitted by babyuniverse on Sun, 2010-06-13 00:38.

Hi,

Can you please advise how to amend this slightly so it opens the buy url in a new window - target=_blank

Thanks
Richard

Submitted by support on Mon, 2010-06-14 08:23.

Hi Richard,

This is best done within the includes/tapestry.php file. In that file, you will find the following code beginning at line 51:

    if ($config_useTracking)
    {
      return $config_baseHREF."jump.php?id=".$product["id"];
    }
    else
    {
      return $product["buy_url"];
    }

REPLACE that with:

    if ($config_useTracking)
    {
      $retval = $config_baseHREF."jump.php?id=".$product["id"];
    }
    else
    {
      $retval = $product["buy_url"];
    }
    return $retval."' target='_BLANK";

It may look like there is a ' missing after _BLANK, but that's OK - it' balanced out by the additional ' added after the Buy URL ($retval in the above code), so the HTML that is ultimately generated will be valid!

Cheers,
David.