feat: Add promo codes
All checks were successful
Build Docker / Build Image (push) Successful in 21s
All checks were successful
Build Docker / Build Image (push) Successful in 21s
This commit is contained in:
37
render.py
37
render.py
@@ -68,7 +68,7 @@ def cart_total(cert):
|
||||
price = prices[path]
|
||||
else:
|
||||
name = path
|
||||
image = "tech/image2.jpg"
|
||||
image = "pins/pack1.jpg"
|
||||
price = 45
|
||||
|
||||
hns = usdToHNS(price, True)
|
||||
@@ -122,7 +122,7 @@ def usdToHNS(usd, returnInt=False):
|
||||
return hns
|
||||
|
||||
|
||||
def total_usd(cert):
|
||||
def total_usd(cert,promo):
|
||||
total = 0
|
||||
for item in cert:
|
||||
path = item['name']
|
||||
@@ -130,18 +130,33 @@ def total_usd(cert):
|
||||
total += prices[path] * int(item['quantity'])
|
||||
else:
|
||||
total += 45 * int(item['quantity'])
|
||||
|
||||
if promo:
|
||||
if promo["constant"]:
|
||||
total -= int(promo["constant"])
|
||||
else:
|
||||
total = total - (total * int(promo["percent"]) / 100)
|
||||
|
||||
return total
|
||||
|
||||
def total_hns(cert, returnInt=False):
|
||||
total = 0
|
||||
for item in cert:
|
||||
path = item['name']
|
||||
if path in prices:
|
||||
total += usdToHNS(prices[path],True) * int(item['quantity'])
|
||||
else:
|
||||
total += usdToHNS(45,True) * int(item['quantity'])
|
||||
def total_hns(cert, promo, returnInt=False):
|
||||
total = total_usd(cert, promo)
|
||||
total = usdToHNS(total,True)
|
||||
|
||||
if returnInt:
|
||||
return int(total)
|
||||
total ="{:,}".format(total)
|
||||
return total
|
||||
return total
|
||||
|
||||
|
||||
def promoList(promo):
|
||||
html = '<ul class="list-group">'
|
||||
for item in promo:
|
||||
discount = 0
|
||||
if item['constant']:
|
||||
discount = "$"+item['constant']
|
||||
else:
|
||||
discount = item['percent'] + '%'
|
||||
html += f'<li class="list-group-item"><span>Code: {item["id"]} | {discount} off (Uses Left {item["uses"]})</span><a class="btn btn-primary align-right" role="button" href="/promo/delete/{item["id"]}">Delete</a></li>'
|
||||
html += '</ul>'
|
||||
return html
|
||||
Reference in New Issue
Block a user