Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Switch off the product


YePix

Recommended Posts

Hello everyone, I would like to add an end date to my products.

Any product that exceeds this end date should switch itself off automatically.
Here I have the query that I want to add to the application_top.php, which sets the product status to 0 but I'm not sure if it fits. I ask because I have no way to test it and I can't afford to make any mistakes in my shop.

Could someone take a look at it and give me some advice on whether it works that way? thank you in advance.

// Set the product status by out of available to 0
if (isset($_GET['products_id'])) {    
  tep_db_query('update ' . TABLE_PRODUCTS . ' set products_status = '0' where products_id = '" . (int)$_GET['products_id'] . "' and  products_out_available > curdate()');
}

 

Link to comment
Share on other sites

I would have a look at how specials expire from the tep_expire_specials function in includes/functions/specials.php

////
// Sets the status of a special product
  function tep_set_specials_status($specials_id, $status) {
    return tep_db_query("update specials set status = '" . (int)$status . "', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");
  }

////
// Auto expire products on special
  function tep_expire_specials() {
    $specials_query = tep_db_query("select specials_id from specials where status = '1' and now() >= expires_date and expires_date > 0");
    if (tep_db_num_rows($specials_query)) {
      while ($specials = tep_db_fetch_array($specials_query)) {
        tep_set_specials_status($specials['specials_id'], '0');
      }
    }
  }

then try to construct something from there.

Link to comment
Share on other sites

you can also look at one of the featured products add ons. Wolfen Featured Sets comes to mind.

You need to start by creating an input for the date to expire on every product_id. So you will need to modify categories.php

Then build your tep_expire_ function and call it in application_top.php

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...