You are here:  » Disable "Visit Store" button


Disable "Visit Store" button

Submitted by falmeida on Mon, 2015-09-21 10:50 in

Hi David

Is it possible to disable the "Visit Store" button if the useragent is a bot like googlebot or bingbot etc..

Submitted by support on Mon, 2015-09-21 12:06

Sure - if you edit html/prices.php and first add the following code to the very top of the script:

<?php
  $agents 
= array("googlebot","bingbot");
  foreach(
$agents as $agent)
  {
    if (
stripos($_SERVER["HTTP_USER_AGENT"],$agent)!==FALSE)
    {
      
$hide TRUE;
    }
  }
?>

With that in place, you can remove any content you don't want to be included by enclosing the HTML / code within the following IF construct:

<?php if (!isset($hide)):?>
...
<?php endif; ?>

So for the Visit Store button in the default template, look for the following code at line 76:

<td class='pt_pr_visit'><a class='button tiny radius success' href='<?php print tapestry_buyURL($product); ?>'><?php print translate("Visit Store"); ?></a></td>

...and REPLACE with:

<?php if (!isset($hide)):?>
<td class='pt_pr_visit'><a class='button tiny radius success' href='<?php print tapestry_buyURL($product); ?>'><?php print translate("Visit Store"); ?></a></td>
<?php else: ?>
<td>&nbsp;</td>
<?php endif; ?>

Cheers,
David.
--
PriceTapestry.com

Submitted by falmeida on Mon, 2015-09-21 12:41

Thank you David

Submitted by falmeida on Mon, 2015-09-21 17:40

hi again david
just tested on my website and it seems to always hide the links whatever the user agent is

Submitted by support on Mon, 2015-09-21 17:52

Hi,

Sorry about that - the $agent parameter in the string comparison was missing - corrected above in this line;

    if (stripos($_SERVER["HTTP_USER_AGENT"],$agent)!==FALSE)

Cheers,
David.
--
PriceTapestry.com

Submitted by falmeida on Mon, 2015-09-21 17:57

thx david its working now