Zen Cart Logo
Forums / Basic Configuration / Setting products to expire at certain date

Setting products to expire at certain date

Locked

Views: 10,196

Results 1 to 20 of 40
This thread is locked. New replies are disabled.
21 Apr 2008, 3:51 PM
#1
jlavetan avatar

jlavetan

New Zenner

Join Date:
Feb 2004
Posts:
3
Plugin Contributions:
1

Setting products to expire at certain date

I have seen plenty of posts concerning having products expire, but I cannot find a solution.

We are setting up a site that only has promotions, so all products will expire monthly. New products will be uploaded via EasyPopulate and will be set active and expire 30 days later.

Is something like this possible?

I know there's the ability to do featured products, but we want to do this on a bulk scale (100+ at a time).

21 Apr 2008, 4:05 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Setting products to expire at certain date

There would be several ways of approaching this - none of them ideal.

The most simple but manual way would be to use EasyPopulate to set the product_status to 0 for products which have expired.

Depending upon the number of products, you could put them in a hidden category where they wouldn't be seen normally, and then use banners to draw attention to them. Banners have expiry dates already built-in, so they would appear to disappear off the site when their expiry date passed, though somebody who knows (or guesses) the product ID would still be able to uncover them. This is probably only practical anyway for small numbers of products.

Another, and more robust approach, would be to add a product expiry date to the database. And then amend the database queries to look not just at date available, but also at "date of expiry". However, you would also need to amend easy populate for it to also recognise the new field, or to amend the admin to be able to enter and maintain the new field .

21 Apr 2008, 11:08 PM
#3
stevecollins avatar

stevecollins

New Zenner

Join Date:
Aug 2005
Location:
Southampton
Posts:
80
Plugin Contributions:
0

Re: Setting products to expire at certain date

I also have been searching for this and would love to know how you would go about coding this. I was looking at trying to corrupt the coding that is used for specials and see if i could make it fit. So far no success in including it in products_general.

Anyone have any ideas and i would be very interested.

22 Apr 2008, 3:23 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Setting products to expire at certain date

You would need to add a new field to the products table such as:
products_date_expired

These should be datetime fields with the default of NULL ...

Then, in a similar manner to how banners are made to be disabled or stopped by date, this can done ...

You have to be careful of the midnight hour, just like in the banners ...

This would require updating the admin code for adding/updating products and those files do not have overrides so be sure you keep a copy of original data and your customizations ...

If you have your coder's hat on ... are good to go ... :smartalec:

If your eyes are glazing over about now, perhaps the Commercial Help wanted would help ...

This is something on the list for a future release of Zen Cart ... :smile:

23 Apr 2008, 12:20 AM
#5
vivaraquel avatar

vivaraquel

Zen Follower

Join Date:
Sep 2004
Location:
Australia
Posts:
305
Plugin Contributions:
0

Re: Setting products to expire at certain date

I really need this customization and I can't finish my site due to its nature without it.

I have added a field named products_date_expires to my db.
The settings for this field are as follows:

field: products_date_expires
type: datetime
length/values:
collation:
attributes:
null: yes
default: null
extra:
primary:
index:
unique:
---: radio button on
fulltxt:
Comments:
mime type:
browser transformation:
transformation options:

Obviously I don't know much about dbs so I probably didn't add something I should have added or entered.

The next step I am assuming would be to enter the define statement for this in its appropiate file which I think it is admin/includes/languages/english/products.php?

From there on I have no more ideas, another hint would be nice please. I don't mind finding my way around but a map is always useful.

I thought I'd look in the zen_specials table for a clue but so far I am blind to it.

Thank you.

23 Apr 2008, 11:46 AM
#6
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Setting products to expire at certain date

I don't think that the specials code is going to be a great deal of help to you. That filters what products are listed, but it sounds as though you actually need to turn off the expired products - which happily would be easier.

For this the map would be:

  1. database change (the easy bit that you've already done)
  2. changes to admin code to maintain the expiry date (this is the trickiest bit and would probably require you to change the collect_info, preview_info and update_product scripts for the relevant product type, and possibly other scripts such as copy_to_confirm)
  3. write a database query to find and update products that are still active but have passed their expiry date and integrate it into a PHP script
  4. schedule a CRON job to schedule the update script.Although not advanced, this would require a reasonable grasp of PHP and SQL and a willingness to plod through some old, tables-laden code to find the right places to insert your changes. If you aren't a reasonably experienced developer, then Ajeh's advice about the commercial help wanted section of the forum, might be the most appropriate way to go.
23 Apr 2008, 1:33 PM
#7
vivaraquel avatar

vivaraquel

Zen Follower

Join Date:
Sep 2004
Location:
Australia
Posts:
305
Plugin Contributions:
0

Re: Setting products to expire at certain date

Thank you Kuroi, I'll look into the commercial help for it as I am definitely not that advanced at all. Maybe one day........

Thank yuo.

26 Apr 2008, 12:24 AM
#8
stevecollins avatar

stevecollins

New Zenner

Join Date:
Aug 2005
Location:
Southampton
Posts:
80
Plugin Contributions:
0

Re: Setting products to expire at certain date

Thanks Ajeh & Kuroi. I will have a go on my test site and post for the benefit of vivaraquel if I get there.

26 Apr 2008, 1:22 AM
#9
vivaraquel avatar

vivaraquel

Zen Follower

Join Date:
Sep 2004
Location:
Australia
Posts:
305
Plugin Contributions:
0

Re: Setting products to expire at certain date

SteveCollins:

Thanks Ajeh & Kuroi. I will have a go on my test site and post for the benefit of vivaraquel if I get there.

Thank you Steve Collins. I would appreciate that.

14 Oct 2009, 5:34 AM
#10
perfectino avatar

perfectino

New Zenner

Join Date:
Mar 2009
Posts:
14
Plugin Contributions:
1

Re: Setting products to expire at certain date

Here you have the mod complete to setup an expiry date for any product.
It will diable automatically the product after the specified date.

Ideal for ticket selling, events dates, workshops and events reservation, etc...

You can globally disable this feature by going to: admin, product listing,Use product expire date featured, enable or disable.

Language files are English, French and Dutch

I do not know how to upload as a mod so I post the file here.

You can see the mod in action at https://www.perfectino.fr/store under workshops

14 Oct 2009, 7:00 AM
#11
kiddo avatar

kiddo

Totally Zenned

Join Date:
Jul 2006
Location:
SF Bay Area
Posts:
837
Plugin Contributions:
1

Re: Setting products to expire at certain date

How about a simple cron job that deletes or disables products based on the date added?

15 Oct 2009, 11:20 AM
#12
perfectino avatar

perfectino

New Zenner

Join Date:
Mar 2009
Posts:
14
Plugin Contributions:
1

Re: Setting products to expire at certain date

not everyone can use or manage a cron job. You need access to your server files and it requires some programming knowledge. Try the mod I posted, it is very easy and flexible to use.
It also let you display a category with no product in it (as product with later expiry date will not show up.

15 Dec 2009, 11:45 AM
#13
enquirer66 avatar

enquirer66

Zen Follower

Join Date:
Sep 2007
Posts:
215
Plugin Contributions:
0

Re: Setting products to expire at certain date

Have tried this but get some error message - has anyone installed this ok?

Error on a product: 1054 Unknown column 'p.products_bundle' in 'field list'
in:
[select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_virtual, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, date_format(p.products_date_expire, '%Y-%m-%d') as products_date_expire, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max, p.products_sort_order, p.products_discount_type, p.products_discount_type_from, p.products_price_sorter, p.master_categories_id, p.products_bundle from fws_products p, fws_products_description pd where p.products_id = '97' and p.products_id = pd.products_id and pd.language_id = '1']
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

And when I call up the site:

[15-Dec-2009 06:36:09] PHP Warning: Cannot modify header information - headers already sent by (output started at /usr/home/account/public_html/website/includes/languages/english.php:1406) in /usr/home/account/public_html/website/includes/init_includes/init_templates.php on line 78
[15-Dec-2009 06:36:09] PHP Fatal error: require() [<a href='function.require'>function.require</a>]: Failed opening required 'includes/index_filters/default' (include_path='.:/usr/local/lib/php') in /usr/home/account/public_html/website/includes/modules/pages/index/header_php.php on line 49

15 Dec 2009, 11:55 AM
#14
enquirer66 avatar

enquirer66

Zen Follower

Join Date:
Sep 2007
Posts:
215
Plugin Contributions:
0

Re: Setting products to expire at certain date

OK may have made a mistake. So ignore above. Can you make it clearer where to put the code to show the expires? Thanks.

16 Dec 2009, 6:26 AM
#15
enquirer66 avatar

enquirer66

Zen Follower

Join Date:
Sep 2007
Posts:
215
Plugin Contributions:
0

Re: Setting products to expire at certain date

Since this is potentially quite useful I set up a new test site (1.38a) and loaded this module which seems to work fine - thanks for the work on this. But when I tried again to load it on my site when one calls up a specific product one gets this error message (as above):

1054 Unknown column 'p.products_bundle' in 'field list'
in:
[select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_quantity, p.products_weight, p.products_priced_by_attribute, p.product_is_free, p.products_qty_box_status, p.products_quantity_order_max, p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter,p.products_bundle from fws_products p, fws_products_description pd where p.products_status = '1' and p.products_id = '73' and pd.products_id = p.products_id and pd.language_id = '1']

Maybe there is some conflict with another module where one of the files has been modified or my theme (simple zen)?

Can you suggest anything? Thanks.

16 Dec 2009, 11:18 AM
#16
enquirer66 avatar

enquirer66

Zen Follower

Join Date:
Sep 2007
Posts:
215
Plugin Contributions:
0

Re: Setting products to expire at certain date

Actually, the clean install didn't work either (same kind of error message above) and now neither site permits new products to be added. I tried restoring database and it didn't work! Any suggestions would be much appreciated as I can't seem to remove this module at all!!! HELP!

17 Dec 2009, 10:19 AM
#17
perfectino avatar

perfectino

New Zenner

Join Date:
Mar 2009
Posts:
14
Plugin Contributions:
1

Re: Setting products to expire at certain date

Problems arise because installation files comes from a modified zencart installation.

I will upload installation files for a new clean version of zencart 1.3.8a.

17 Dec 2009, 10:50 AM
#18
enquirer66 avatar

enquirer66

Zen Follower

Join Date:
Sep 2007
Posts:
215
Plugin Contributions:
0

Re: Setting products to expire at certain date

All seems to come from coding provided by momleetech regarding something I didn't even want in the files which was to do with product bundling....

17 Dec 2009, 11:46 AM
#20
enquirer66 avatar

enquirer66

Zen Follower

Join Date:
Sep 2007
Posts:
215
Plugin Contributions:
0

Re: Setting products to expire at certain date

Thanks but any idea how I can get rid of this problem addressing the products_bundle....? Where does it come from?