027
This commit is contained in:
parent
23f8f7b0ba
commit
3cc35531c4
BIN
db5.sqlite3
BIN
db5.sqlite3
Binary file not shown.
42
src/a3.nim
42
src/a3.nim
@ -217,6 +217,48 @@ import
|
|||||||
|
|
||||||
compileTemplateFile(getScriptDir() / "a3a" / "checkout.nimja")
|
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:
|
"/contact" -> get:
|
||||||
|
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user