You are here:  » Voucher Code Info Appearing on product pages


Voucher Code Info Appearing on product pages

Submitted by bodybuildingcom... on Tue, 2015-03-10 09:25 in

Hi David,

I am wondering if there is any way of embedding related voucher codes on related product pages?
I would assume that may be a bit more complicated. For example, I am looking to embed the voucher codes for {link saved}, with the {link saved} product pages. I am wondering if this is possible.

I saw it is possible to embed the voucher codes into related search results pages:
'Voucher Code Info Appearing on Query Search Results Page'- http://www.pricetapestry.com/node/5259.

So, I am wondering if we can go one beyond, and embed them into related product pages?

Please let me know if it doesn't make sense?

Thanks.

Norbert

Submitted by support on Tue, 2015-03-10 09:50

Hello Norbert,

Sure - the code would be almost identical - to keep it contained within your template and to display above the product info, try adding the following at the very top of html/product.php:

<?php
$sql 
"SELECT * FROM `".$config_databaseTablePrefix."vouchers`
         WHERE merchant='"
.database_safe($product["products"][0]["merchant"])."'";
if (
database_querySelect($sql,$vouchers))
{
  print 
"<ul>";
  foreach(
$vouchers as $voucher)
  {
    switch(
$voucher["discount_type"])
    {
      case 
"#":
        
$text translate("Save")." ".$config_currencyHTML.$voucher["discount_value"];
        break;
      case 
"%":
        
$text translate("Save")." ".$voucher["discount_value"]."%";
        break;
      case 
"S":
        
$text $voucher["discount_text"];
        break;
    }
    if (
$voucher["min_price"] > 0)
    {
      
$text .= " ".translate("when you spend")." ".$config_currencyHTML.$voucher["min_price"];
    }
    if (
$voucher["match_value"])
    {
      
$text .= " ".translate("on selected products");
    }
    
$text .= " ".translate("using voucher code")." <strong>".$voucher["code"]."</strong>";
    print 
"<li>".$text."</li>";
  }
  print 
"</ul>";
}
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by bodybuildingcom... on Tue, 2015-03-10 22:16

Hi David,

Much appreciate it. It worked. Fantastic support as always.

Thanks.

Norbert