Hello all, I was wondering how to do promotions for products that have a 
time limit to it? An example of this would be Valve's Steam, where each 
individual game can have a unique promotion which ends after a certain time 
is passed. The promotion can be tied to an individual product, to groups of 
products, or all products in a site-wide promotion.

I'm thinking that each product would have a python datetime associated that 
defines the end of the promotion.

db.define_table('myproducts',
          Field('name'),
          Field('description'),
          Field('original_price'),
          Field('promo_price'),
          Field('promotion_end', 'datetime', default=None))  # 
'promotion_end' should be None if no promotion is active

Then, whenever a product is going to be on sale or something, I can update 
that product's promotion_end. A javascript timer would use this date and 
countdown from it on the website, so that the user can see how long there 
is until the promotion ends for that product. For groups of products, it's 
just updating the promotion_end for multiple products. For site-wide, I 
would just update the promotion_end for all products.

When a promotion is active, the promo_price will show (probably calculated 
dynamically depending on the how large the discount is). When the promotion 
is inactive, the original_price will show.

There are a few problems I don't understand how to solve:

- I will probably have to write a script to update the promotion_end for 
the products when a promotion is going to happen. Where will this script 
live (in the modules folder?) and when/where should it be executed?

- Since the timer is ticking down on the client-side (using a javascript 
countdown timer), how will the server know when a promotion has ended so 
that it can immediately update the site's html to hide any signs of the 
expired promotion? The server will also have to reset to its original price 
instead of the promo price and set the promotion_end to None.
  
     For example, when a promotion is active on a product, the html will 
display original_price crossed out and display the promo_price in big 
letters. When the promo is inactive, the html should show only the 
original_price and the countdown timer should not be shown at all.

- In reference to the previous question, if the server needs to keep track 
of the time left of a promotion, what happens if an email is to be sent out 
24 hours before the promotion ends? This implies that the server needs to 
consistently keep track of all active promotions and their respective end 
times. Does web2py have some sort of mechanism (maybe some sort of python 
thread?) that will actively keep track of this?

I'm not familiar with database design or web2py in-depth, so any help or 
ideas would be great.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to