Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Product Expiry Date


Recommended Posts



I was wondering how easy it would be to create a product expiry date, which would automatically remove the product from the store once the expiry date passed.


Can anyone guide me in the right direction?



Link to comment
Share on other sites

Looking at this in more detail it appears that the expiry date mechanism can be achieved using code from specials.php and banner.php in the catalog-->Includes-->Functions directory.


I have put together the following but it doesn't seem to work. Can someone have a look at the code and see what I have missed.


First I created a new date field in the products table in the database called products_expire


Next I created a new file in the Functions directory called products_expire.php, which is made up of the following code:




// Auto expire products

function tep_expire_products() {

$products_query = tep_db_query("select products.products_id, products.products_expire from " . TABLE_PRODUCTS . " where products.products_status = '1'");

if (tep_db_num_rows($products_query)) {

while ($products = tep_db_fetch_array($products_query)) {

if ($products['expires_date']) {

if (date('Y-m-d H:i:s') >= $products['products_expire']) {

tep_set_product_status($products['products_id'], '0');









I then added the following to application_top.php


// auto expire products

require(DIR_WS_FUNCTIONS . 'products_expire.php');



If anyone could help, I would be much obliged.



Link to comment
Share on other sites

I think the problem arises in this section.


if ($products['expires_date'])


However, I'm not 100% sure where ['expires_date'] is defined, or what it defines.


Could it be this part I need to change?

Link to comment
Share on other sites

  • 11 months later...


This topic is now archived and is closed to further replies.

  • Create New...