You are here:  » Voucher Description Entry Field


Voucher Description Entry Field

Submitted by kend on Sat, 2016-01-09 18:22 in

Hi David,

All the other expected fields are in the voucher edit form, but not the "description" field (voucher_codes_edit.php).

I tried to create a "description" field using the process here: http://www.pricetapestry.com/node/5837, and I have a table field "description" now, and form "Description" data entry box, but form doesn't write to table on save. Note, I did not complete final step: "in vouchers.php look for the following code at line 17", because I thought the description field didn't apply to search.

Before I proceed further, am I "missing something" with setup of voucher descriptions?

Thanks!
Ken.

Revision 14/06

Submitted by support on Mon, 2016-01-11 09:24

Hello Ken,

That should work fine assuming a replacement of "link" with "description" but for completeness, to add a description field you first run the following dbmod.php script:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."vouchers`
            ADD `description` TEXT NOT NULL"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

And then modify admin/voucher_codes_edit.php as follows:

The to add the field to the edit voucher code form, in admin/voucher_codes_edit.php look for the following code at line 152:

                      valid_to = '%s'

...and REPLACE with:

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

Then look for the following code at line 164:

                      database_safe($_POST["valid_to"])

...and REPLACE with:

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

And to add the form field, look for the following code at line 404:

    print "</fieldset>";

...and REPLACE with:

      widget_textBox("Description","description",FALSE,(isset($_POST["description"]) ? $_POST["description"] : ""),"",12);
    print "</fieldset>";

With that in place, look for the following code in vouchers.php at line 50:

  $vouchers[$k]["text"] .= " ".translate("using voucher code")." <strong>".$voucher["code"]."</strong>";

...and to use the new description field in addition to the auto-generated description, REPLACE with:

  $vouchers[$k]["text"] .= " ".translate("using voucher code")." <strong>".$voucher["code"]."</strong>";
  $vouchers[$k]["text"] .= " ".$voucher["description"];

...or to use the new description field exclusively:

  $vouchers[$k]["text"] = $voucher["description"];

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by kend on Mon, 2016-01-11 15:13

Yes, this very complete answer helped a lot, thank you!