diff --git a/db5.sqlite3 b/db5.sqlite3 index 042280b..bc8d43d 100644 Binary files a/db5.sqlite3 and b/db5.sqlite3 differ diff --git a/src/a3 b/src/a3 index 3c2fb3b..d4359a4 100755 Binary files a/src/a3 and b/src/a3 differ diff --git a/src/a3.nim b/src/a3.nim index a62f650..20b1aa6 100644 --- a/src/a3.nim +++ b/src/a3.nim @@ -4,6 +4,7 @@ import os, nimja/parser, strutils, + strformat, ./a3pkg/[models, mics], ./a3c/[products, users, cart] @@ -80,6 +81,49 @@ import compileTemplateFile(getScriptDir() / "a3a" / "cart.nimja") +"/update-cart" -> get: + + var + email: string + password: string + db = newDatabase() + products: seq[Products] + form = ctx.urlForm + echo form + + try: + email = ctx.cookies["email"] + password = ctx.cookies["password"] + except: + email = "" + password = "" + + if email == "": + ctx.redirect("/login") + + else: + products = micsGetProducts(email, password) + var + userId = db.getUserId(email, password) + cart = db.getUserCart(userId) + cook = ctx.cookies + + # echo cart + # echo cook + # db.updateCart(cook) + + for d, e in cook: + if d.contains("_quantity") == true: + var h = d.split("_") + echo h + for i, j in cart: + # echo i + # echo j + if j.productId == parseInt(h[0]): + db.updateCart(e, j.id) + + ctx.redirect("/cart") + "/add-to-cart" -> get: var diff --git a/src/a3a/cart.nimja b/src/a3a/cart.nimja index e02492e..c470bcd 100644 --- a/src/a3a/cart.nimja +++ b/src/a3a/cart.nimja @@ -103,7 +103,7 @@