Jump to content
Sign in to follow this  
YePix

Switch off the product

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()');
}

 

Share this post


Link to post
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.

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×