This commit is contained in:
Aritra Banik 2024-02-10 21:58:50 +05:30
parent 23f8f7b0ba
commit 3cc35531c4
3 changed files with 42 additions and 0 deletions

Binary file not shown.

BIN
src/a3

Binary file not shown.

View File

@ -217,6 +217,48 @@ import
compileTemplateFile(getScriptDir() / "a3a" / "checkout.nimja")
"/checkout" -> post:
var
email: string
password: string
db = newDatabase()
productName= ""
quantity = 0
cart: seq[Cart]
products: seq[Products]
price = 0.0
try:
email = ctx.cookies["email"]
password = ctx.cookies["password"]
except:
email = ""
password = ""
if email == "":
try:
productName = ctx.queryParams["prod"]
quantity = parseInt(ctx.queryParams["quantity"])
except:
productName = ""
quantity = 0
if productName == "":
ctx.redirect("/login")
price = db.getPriceByProductName(productName)
else:
var
userId = db.getUserId(email, password)
cart = db.getUserCart(userId)
for c, d in cart:
var product = db.getProductById(d.productId)
products.add(product)
compileTemplateFile(getScriptDir() / "a3a" / "checkout.nimja")
"/contact" -> get:
var