compute item amount from query string (#9174)
This commit is contained in:
parent
f497a9c8ad
commit
2a31f515cd
7
README
7
README
|
@ -25,7 +25,7 @@ API
|
|||
|
||||
Items amount can be added to basket through API by posting to
|
||||
*/api/lingo/add-basket-item* endpoint a json payload containing *amount* and/or
|
||||
*"extra": {"amount": ...}* attribute.
|
||||
*"extra": {"amount": ...}* attribute or passing *amount* in the query string
|
||||
|
||||
For example:
|
||||
|
||||
|
@ -34,7 +34,10 @@ For example:
|
|||
"amount": "42.42",
|
||||
"extra": {"amount": "10.42", ...},
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
or
|
||||
/api/lingo/add-basket-item?amount=10
|
||||
|
||||
The "amount" attribute should be float or decimal or a list of
|
||||
floats/decimals. For example:
|
||||
|
|
|
@ -69,6 +69,7 @@ class AddBasketItemApiView(View):
|
|||
extra = request_body.get('extra', {})
|
||||
|
||||
item = BasketItem(amount=0)
|
||||
item.amount = sum([Decimal(x) for x in request.GET.getlist('amount')])
|
||||
|
||||
if request_body.get('amount'):
|
||||
item.amount += self.get_amount(request_body['amount'])
|
||||
|
|
Reference in New Issue