Anonymous     Python     05 Apr 2012    
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def xhr_cartsum(request):
if request.is_ajax():
summ = 0
order = request.session.get('order', [])
for item in order:
price = Goods.objects.get(pk=item['id']).price
summ += int(item['q']) * int(price)
return HttpResponse(str(summ))
else:
return HttpResponse('')