added filtering by discount to product search

This commit is contained in:
Sam
2021-02-23 12:06:57 +00:00
parent 7ca180f8e6
commit 31066e80bf
3 changed files with 71 additions and 5 deletions

View File

@@ -163,6 +163,15 @@ def product_search(request):
shipping_cost = False
else:
shipping_cost = None
discount = request.GET.get('discount', None)
if discount is not None:
if discount == 'true':
discount = True
elif discount == 'false':
discount = False
else:
discount = None
if query_string is None:
return Response({"errors": {"details": "No query string to parse"}})
elif query_string is '':
@@ -175,7 +184,7 @@ def product_search(request):
# split query string into single words
chunks = query_string.split(' ')
for chunk in chunks:
product_set = find_related_products_v6(chunk, shipping_cost)
product_set = find_related_products_v6(chunk, shipping_cost, discount)
# add to result set
result_set.update(product_set)
# TODO: add search for entire phrase ???