thanks all for the pointer, yet it still not work as expected.
e.g.
def purchase_order_callback():
id = int(request.vars.id)
quantity = session.purchase_order.get(id, 0)
price = session.purchase_order.get(id, 0)
if request.vars.action == 'add':
quantity = max(0, quantity + 1)
price = max(0, price + 2)
session.purchase_order[id] = dict(quantity = quantity, price =
price )
#session.purchase_order[id] = max(0, quantity + 1)
return str(session.purchase_order[id])
if request.vars.action == 'subtract':
quantity = max(0, quantity + 1)
price = max(0, price + 2)
session.purchase_order[id] = dict(quantity = quantity, price =
price )
#session.purchase_order[id] = max(0, quantity - 1)
return str(session.purchase_order[id])
if request.vars.action == 'adjust_total_price':
quantity = int(request.vars['quantity_%s' % id])
price = int(request.vars['price_%s' % id])
session.purchase_order[id] = dict(quantity = quantity, price =
price)
total_price = quantity * price
grand_total = 0
for calculation_id, calculation_quantity, calculation_price in
session_purchase_order.items():
product = db.product(calculation_id)
calculation_total_price = calculation_quantity *
calculation_price
grand_total += calculation_total_price
print session
return
"jQuery('#total_price_%s').html(%s);jQuery('#grand_total').html(%s);" %
(str(id), str(total_price), str(grand_total) )
1. when i click the add for the first time in purchase_cart page it shows :
{'price': 2, 'quantity': 1} In Order
*views/transaction/purchase_cart.html*
{{=SPAN(session.purchase_order.get(row.id, 0), _id="item_%s" % row.id) }}
{{=T('In Order') }}
my expected result is just show the quantity value, how can i achieve it?
2. still on the same page, when i click the add / substract after that, an
error occured
Traceback (most recent call last):
File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 217, in
restricted
File
"C:/Users/sugizo/Desktop/web2py/2.8.2/applications/citifone/controllers/transaction.py"
<http://127.0.0.1:8000/admin/default/edit/citifone/controllers/transaction.py>,
line 261, in <module>
File "/home/mdipierro/make_web2py/web2py/gluon/globals.py", line 372, in
<lambda>
File
"C:/Users/sugizo/Desktop/web2py/2.8.2/applications/citifone/controllers/transaction.py"
<http://127.0.0.1:8000/admin/default/edit/citifone/controllers/transaction.py>,
line 134, in purchase_order_callback
quantity = max(0, quantity + 1)
TypeError: unsupported operand type(s) for +: 'dict' and 'int'
how can i fix it?
3. when i click checkout it return an error :
Traceback (most recent call last):
File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 217, in
restricted
File
"C:\Users\sugizo\Desktop\web2py\2.8.2\applications\citifone\views\transaction/purchase_order.html",
line 115, in <module>
TypeError: unsupported operand type(s) for *: 'dict' and 'int'
how can i fix it?
4. as you can see the traceback on no 2 and 3, so my question is what is
the difference between * and + on that error :
TypeError: unsupported operand type(s) for *+*: 'dict' and 'int'
TypeError: unsupported operand type(s) for ***: 'dict' and 'int'
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/groups/opt_out.