a, i c, the controller do the job, i've searched on the google that the 
others (magento, prestashop, oracle, etc) using tables (promotion, pricing 
rules, cart rules, etc) to handle it. put the condition on table and then 
compare it using controller, please correct me if i'm wrong.

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.

thanks and best regards,
stifan

On Saturday, December 27, 2014 3:32:04 PM UTC+7, Massimo Di Pierro wrote:
>
> db.define_table('product',
>    Field('name'),
>    Field('price'))
>
> pen = db.product.insert(name="Pen", price="8 if self>4 else 10 if self>2 
> else 12")
>
> 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())
>
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to