You are here:  » Custom Voucher Content


Custom Voucher Content

Submitted by chrisst1 on Mon, 2013-06-10 16:13 in

Hi David

I am just upgrading our voucher admin to the new 'Voucher Code (Feed Assisted)', we have two custom fields (description, landing_url) in our current voucher code set up and was wondering if its possible to map the full description and url to those fields during the add process.

Chris

Submitted by support on Tue, 2013-06-11 08:41

Hello Chris,

Should be straight forward - pretty much the same process as adding custom fields to the normal feed registration process, but note that the feed based system already has a field called `description` so on the `voucherfeeds` table I'll call that `fulldescription` instead...

Firstly, run the following dbmod.php script to add corresponding `field_` fields for your custom fields to the `voucherfeeds` table:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."voucherfeeds`
            ADD `field_fulldescription` VARCHAR(255) NOT NULL,
            ADD `field_landing_url` VARCHAR(255) NOT NULL
            "
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Next, edit config.advanced.php and look for the following code at line 64:

  $config_voucherCodesFieldSet["description"] = "Description";

...and REPLACE with:

  $config_voucherCodesFieldSet["description"] = "Description";
  $config_voucherCodesFieldSet["fulldescription"] = "Full Description";
  $config_voucherCodesFieldSet["landing_url"] = "Landing URL";

Finally, edit admin/voucher_codes_edit.php and look for the following code at line 130:

  valid_to = '%s'

...and REPLACE with:

  valid_to = '%s',
  description = '%s',
  landing_url = '%s'

And then the following code at line 142:

  database_safe($_POST["valid_to"])

...and REPLACE with:

  database_safe($_POST["valid_to"]),
  database_safe($_POST["description"]),
  database_safe($_POST["landing_url"])

And then the following code at line 211:

  $_POST["code"] = $_GET["code"];

...and REPLACE with:

  $_POST["code"] = $_GET["code"];
  $_POST["description"] = $voucherRecord[$voucherfeed["field_fulldescription"]];
  $_POST["landing_url"] = $voucherRecord[$voucherfeed["field_landing_url"]];

And finally the following code at line 417:

      print "<br /><br />";

...and REPLACE with:

      print "<br /><br />";
      print "Full Description:<br />";
      $default = (isset($_POST["description"]) ? $_POST["description"] : "");
      widget_textBox("description",$default);
      print "<br /><br />";
      print "Landing URL:<br />";
      $default = (isset($_POST["landing_url"]) ? $_POST["landing_url"] : "");
      widget_textBox("landing_url",$default);
      print "<br /><br />";

Cheers!
David.
--
PriceTapestry.com

Submitted by chrisst1 on Wed, 2013-06-12 15:29

Hi David

Thanks for doing that, I was putting

$_POST["code"] = $_GET["field_fulldescription"];
instead of
$_POST["description"] = $voucherRecord[$voucherfeed["field_fulldescription"]];

I also needed to add

field_fulldescription = '".database_safe($_POST["field_fulldescription"])."',
field_landing_url = '".database_safe($_POST["field_landing_url"])."',

to voucher_feeds_register_step3.php make sure the fields were mapped.

Chris

Submitted by chrisst1 on Wed, 2013-06-12 16:07

Hi David

I've just noticed that some, not all voucher descriptions will 'add'

This for Currys won't and anything else starting with 'Save' or a '£' value:
'Save £50 on selected Neff large kitchen appliances when you trade in your old appliance'
'Trade in your old large kitchen appliance and save £100 on selected Siemens Large kitchen appliances'

yet this for Currys will:

5% off when you buy any free standing fridge and freezers only (excluding chest freezers and products delivered by the manufacturer)

Any ideas what's causing this David

Chris

Submitted by support on Wed, 2013-06-12 17:33

Hi Chris,

The current AW feed is live on the demo site - could you perhaps login to the admin area (username: demo, password: demo) and then go to Voucher Codes and click List alongside the awDiscountCodes.csv feed...

I just tried to add:

Save £50 on selected Neff large kitchen appliances when you trade in your old appliance

...which picked up the £50 discount. For the same code, is "Discount Value and Type" not being pre-populated from this voucher text on your installation?

Matching "Save ..." relies on the
$config_voucherCodesDiscountValuePrefixRegexp
setting in config.advanced.php at line 78, which is by default:

  $config_voucherCodesDiscountValuePrefixRegexp = "(save)";

...so if you could check that is in place, and if still no joy if you could email me your modified voucher_codes_edit.php I'll check it out on my test server for you...

Thanks,
David.
--
PriceTapestry.com

Submitted by chrisst1 on Tue, 2013-06-25 09:39

Hi David

I have managed to fix the problem above, it appears to have been html encoding for (£) sign that was causing the problem. I applied this:

$full_description = $voucherRecord[$voucherfeed["field_fulldescription"]];

if ($config_charset == "utf-8") $full_description = utf8_encode($full_description);

elseif ($config_charset == "iso-8859-1") $full_description = utf8_decode($full_description);

$_POST["description"] = $full_description;

in place of:

$_POST["description"] = $voucherRecord[$voucherfeed["field_fulldescription"]];

Chris