Just a thought:

On Saturday, December 27, 2014 7:25:01 AM UTC-8, 黄祥 wrote:
>
> [...]
>
 

> i'd love to learn from another products and implement it on web2py, but 
> still have no idea how to do it in web2py ways. the reason is if it set on 
> the table, the user (non technical) perhaps in marketing division can 
> change their own conditional pricing rules without any help from technical 
> or developer to set their own marketing idea.
> [...]
>

One way to do this is to make a form that said Marketing Dept User (MDU!) 
would fill in, being permitted to access that form's page by the auth 
settings (auth groups, for instance), and then you just update the database 
with the form.  But I think it would be easy to automate expiring special 
prices by extending Massimo's table:
 

> On Saturday, December 27, 2014 3:32:04 PM UTC+7, Massimo Di Pierro wrote:
>>
>> db.define_table('product',
>>    Field('name'),
>>    Field('price'))
>>
>>
with
Field('start'),
Field('end'),
 


pen = db.product.insert(name="Pen", price="8 if self>4 else 10 if self>2 
>> else 12")
>>
>
and tweak the form so that this statement would insert "start=now', 
end='3014/12/31'" (for the default, datepicker results for specials)
 

>
>> cart = {pen: 3} # 3 pens in cart
>>
>> cart_total = sum(eval(p.price, {'cart':cart,'self':cart[p.id]}) for p in 
>> db(db.product.name.belongs(cart.keys())).select())
>>
>>
and here you'd get more than one row back, and you'd pick the price with 
the lowest number that is valid at the time of the order.
(I think I'd be tempted to handle the quantity discount somewhat similar 
... add 
 Field('threshold')



and now you pick  the row with the lowest price valid for the time period 
and whose threshold is met.

As a future thing, you might want have a scheduler task that every once in 
a while checks for expired prices  and  deletes (if you allow deletes) or 
invalidates rows that expired long enough ago that you don't need them 
around for reference.  And a thought occurs that when the base price 
changes, you can mark the old record expried (by setting the 'end' field to 
yesterday) and adding the new price with a far-off expiration.

Caveat:  most of my experience is with device programming, so I might have 
said somethin above that made the people with business sw experience 
shudder.

Anyway, my two cents.

/dps
 

P.S. You may want to validate the price string so that it only contains 
>> "if, else, and, or, self, cart" strings.
>>
>>
>>
>> On Friday, 26 December 2014 09:39:15 UTC-6, 黄祥 wrote:
>>>
>>> hi,
>>>
>>> i face the similar problem (even more complex) designing the table for 
>>> it.
>>>
>>> condition 1 : time base promotion
>>> promotion price will occured during the valid date (start, end)
>>> e.g. on 1 dec 2014 - 31 dec 2014 the price for product B will be $10, 
>>> usually normal price is $12
>>>
>>> condition 2 : quantity base promotion
>>> promotion price will occured when the quantity order is more than 
>>> quantity that have been set
>>> e.g. buy 3 products B the price will be $10, when buy 1 of product B the 
>>> price is $12 or buy 5 products B the price will be $8, when buy 1 of 
>>> product B the price is $12
>>>
>>> condition 3 : product base promotion
>>> promotion that offer free product when another product is ordered.
>>> e.g. buy 3 products B get 1 product C or buy 5 products B get 2 product 
>>> C and 1 product D
>>>
>>> condition 4 : combination of all 3 aboves
>>> e.g. on 1 dec 2014 - 31 dec 2014 buy 3 products B get 1 product C
>>>
>>> my question is how do i design my table relation for that in web2py way? 
>>> i've seen examples of presta shop add ons for that, but don't know how to 
>>> do it using web2py way, any idea how to achieve that?
>>>
>>> thanks and best regards,
>>> stifan
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to