You are here:  » Include Voucher Description and Expiry Date on Import

Active Forum Topics

Include Voucher Description and Expiry Date on Import

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

Hi David,

I am wondering what's involved to include voucher description and expiry date to product table on import?


Submitted by support on Mon, 2016-01-11 16:21

Hello Ken,

Sure - new fields voucher_description and voucher_valid_to would need to be added to the products table which the following dbmod.php script will perform:

$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
            ADD `voucher_description` TEXT NOT NULL,
            ADD `voucher_valid_to` INT(11) NOT NULL

With the new fields in place, edit includes/tapestry.php and look for the following code at line 246:

  $product["voucher_code"] = $voucher["code"];

...and REPLACE with:

  $product["voucher_code"] = $voucher["code"];
  $product["voucher_description"] = $voucher["description"];
  $product["voucher_valid_to"] = $voucher["valid_to"];

And then the following code at line 260:

  $products[$k]["voucher_code"] = $product["voucher_code"];

...and REPLACE with:

  $products[$k]["voucher_code"] = $product["voucher_code"];
  $products[$k]["voucher_description"] = $product["voucher_description"];
  $products[$k]["voucher_valid_to"] = $product["voucher_valid_to"];

With that in place, and following the next import, wherever a full $product record is in context such as within the foreach() loop in html/prices.php the description field would be available using for example:

<?php print $product["voucher_description"]; ?>

However, the valid_to value is stored as a time() value (seconds since 1/1/1970) so this would need to be displayed using PHP's date() function, for example:

<?php print date("Y-m-d",$product["voucher_valid_to"]); ?>

(which would display the date in the format YYYY-MM-DD)

Hope this helps!


Submitted by kend on Mon, 2016-01-11 17:46

That worked perfectly thank you, and it saved me a bunch of time trying to figure it out!

Submitted by sirmanu on Wed, 2017-09-20 21:04


I have a merchant where the each record have a field if it is a coupon. Example:

product: Panasonic Camera
coupon: DISCOUNT20
description: Save 20% with this coupon
valid_until: 2017-10-04

how do I need to proceed in this case?

First of all, I think I have to add field_voucher, field_description and field_valid_until into pt_feeds so I can map it. Isn't it?

Submitted by support on Thu, 2017-09-21 07:26


If you're referring to a normal product feed that has voucher code fields in addition to product fields (populated for some products) then sure, you can add these as custom fields in the normal way...