You are here:  » Voucher Code Info Appearing on Query Search Results Page


Voucher Code Info Appearing on Query Search Results Page

Submitted by bat on Fri, 2013-11-15 14:24 in

Hi David,
I'm unsure if this is possible, but I'm looking to display the voucher code at the top of the page of results for which the voucher code is applicable.

At the moment, if you click on the voucher details on my voucher code panel, it takes the user to a url like this:
http://www.example.co.uk/search.php?q=voucher:MerchantName:20OFF
bringing up a list of items from that merchant that qualify for the offer that the voucher code is providing.

Is there any way to replicate the voucher code and its info above the search results so that the page can be an effective landing page to direct users to, and for them to see the voucher code info without having to click through to one of the code's applicable products?

Many thanks,
Bat

Submitted by support on Fri, 2013-11-15 14:52

Hello bat,

Sure! In search.php, look for the following code at line 424:

  require("html/banner.php");

...and REPLACE with:

  require("html/banner.php");
  if ($parts[0]=="voucher")
  {
    $sql = "SELECT * FROM `".$config_databaseTablePrefix."vouchers` WHERE merchant='".database_safe($parts[1])."' AND code='".$parts[2]."'";
    database_querySelect($sql,$vouchers);
    $voucher = $vouchers[0];
    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 "<p>".$text."</p>";
  }

The last line:

  print "<p>".$text."</p>";

...can of course be embellished as required, for example by assigning a class and adding the relevant formatting to your CSS - let me know if you're not sure;

Cheers,
David.
--
PriceTapestry.com

Submitted by bat on Fri, 2013-11-15 17:43

Awesome! Thank you David, just what I was looking for :)

Submitted by bat on Tue, 2014-10-28 18:39

Hi David,
What code do I need to add to the above please so that the extra text field is also shown regardless if % or £ discount is included. i.e. Some offers are £5 off for new customers only so I put 'New customers only' in the Offer text field when creating a voucher code.

Oh, and slightly off topic, but how do I delete all the old years in my voucher codes dropdown on Voucher Code backend admin? I tried looking for them in the table in my database but couldn't find it.

Thanks!

Submitted by support on Wed, 2014-10-29 09:11

Hello bat,

In the modification described above, where you have the following block to decide what to display by way of the $text variable:

    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;
    }

...REPLACE with:

    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 = "";
        break;
    }
    $text .= ($text?" ":"").$voucher["discount_text"];

`discount_text` will then be displayed regardless of the discount type.

To show the next 10 years (as in 14/06A) instead of the fixed range displayed by 13/03A, edit includes/widget.php and look for the following code at line 72:

    $y_from = 2010;
    $y_to = $y_from + 10;

...and REPLACE with:

    $y_from = date("Y");
    $y_to = $y_from + 10;

Cheers,
David.
--
PriceTapestry.com

Submitted by bat on Thu, 2014-10-30 23:03

Wonderful! Thank you ever so much