"
return html
def cart_total(cert):
html = ""
for item in cert:
quantity = item['quantity']
if int(quantity) <= 0:
continue
path = item['name']
if path in names:
name = names[path]
image = images[path]
price = prices[path]
else:
name = path
image = "pins/pack1.jpg"
price = 50
hns = usdToHNS(price, True)
hns = hns * int(quantity)
hns = "{:,}".format(hns)
html += f"
{hns} HNS"
html += f"
{name}
"
html += f"
{quantity} Packs
"
html += "
"
return html
def script(path):
html = f"""
"""
return html
def usdToHNS(usd, returnInt=False):
global exchange
if exchange['timestamp'] < datetime.datetime.now().timestamp() - 3600:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=handshake&vs_currencies=usd')
exchange['rate'] = response.json()['handshake']['usd']
exchange['timestamp'] = datetime.datetime.now().timestamp()
hns = usd / exchange['rate']
hns = int(hns / 5) * 5
if returnInt:
return int(hns)
hns = "{:,}".format(hns)
return hns
def total_usd(cert,promo):
total = 0
for item in cert:
path = item['name']
if path in prices:
total += prices[path] * int(item['quantity'])
else:
total += 50 * 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, promo, returnInt=False):
total = total_usd(cert, promo)
total = usdToHNS(total,True)
if returnInt:
return int(total)
total ="{:,}".format(total)
return total
def promoList(promo):
html = '
'
for item in promo:
discount = 0
if item['constant']:
discount = "$"+item['constant']
else:
discount = item['percent'] + '%'
html += f'
Code: {item["id"]} | {discount} off (Uses Left {item["uses"]})Delete