Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Expiry Date


francis

Recommended Posts

Posted

Hi

 

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?

 

Thanks

Posted

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:

 

<?php

 

// 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');

tep_expire_products();

 

If anyone could help, I would be much obliged.

 

Thanks

Posted

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?

  • 11 months later...
Posted

I know no one has looked at this for a while.. but this is just what i need. Anyone know of a way to add an expiry date to a product?

 

Thanks

Archived

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

×
×
  • Create New...