diff --git a/db5.sqlite3 b/db5.sqlite3 index 6768b26..4665bc9 100644 Binary files a/db5.sqlite3 and b/db5.sqlite3 differ diff --git a/src/a3 b/src/a3 index bbc49df..30a93f2 100755 Binary files a/src/a3 and b/src/a3 differ diff --git a/src/a3.nim b/src/a3.nim index 0e5baec..d53ac6b 100644 --- a/src/a3.nim +++ b/src/a3.nim @@ -79,6 +79,34 @@ import compileTemplateFile(getScriptDir() / "a3a" / "cart.nimja") +"/add-to-cart" -> get: + + var + email: string + password: string + db = newDatabase() + + try: + email = ctx.cookies["email"] + password = ctx.cookies["password"] + except: + email = "" + password = "" + + if email == "": + ctx.redirect("/login") + + else: + var + cart: Cart + + cart.userId = db.getUserId(email, password) + cart.productId = db.getProductByName(ctx.queryParams["prod"]).id + + db.addToCart(cart) + + ctx.redirect("/cart") + "/checkout" -> get: var @@ -166,7 +194,7 @@ import productName = ctx.queryParams["prod"] - product = db.getProduct(productName) + product = db.getProductByName(productName) products: seq[Products] diff --git a/src/a3a/shop-single.nimja b/src/a3a/shop-single.nimja index 3e0ad7e..2f13bba 100644 --- a/src/a3a/shop-single.nimja +++ b/src/a3a/shop-single.nimja @@ -99,14 +99,14 @@