4th Commit
This commit is contained in:
parent
6a1e0155b1
commit
71bd264cb2
28
src/a3.nim
28
src/a3.nim
@ -121,6 +121,8 @@ import
|
|||||||
db3 = newDatabase3()
|
db3 = newDatabase3()
|
||||||
db1 = newDatabase1()
|
db1 = newDatabase1()
|
||||||
|
|
||||||
|
products: seq[Products]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
email = ctx.cookies["email"]
|
email = ctx.cookies["email"]
|
||||||
password = ctx.cookies["password"]
|
password = ctx.cookies["password"]
|
||||||
@ -132,7 +134,6 @@ import
|
|||||||
var
|
var
|
||||||
userId = db2.getUserId(email, password)
|
userId = db2.getUserId(email, password)
|
||||||
cart = db3.getUserCart(userId)
|
cart = db3.getUserCart(userId)
|
||||||
products: seq[Products]
|
|
||||||
|
|
||||||
for c, d in cart:
|
for c, d in cart:
|
||||||
var product = db1.getProductById(d.productId)
|
var product = db1.getProductById(d.productId)
|
||||||
@ -150,6 +151,7 @@ import
|
|||||||
db1 = newDatabase1()
|
db1 = newDatabase1()
|
||||||
|
|
||||||
availableProducts = db1.availableProducts()
|
availableProducts = db1.availableProducts()
|
||||||
|
products: seq[Products]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
email = ctx.cookies["email"]
|
email = ctx.cookies["email"]
|
||||||
@ -162,7 +164,6 @@ import
|
|||||||
var
|
var
|
||||||
userId = db2.getUserId(email, password)
|
userId = db2.getUserId(email, password)
|
||||||
cart = db3.getUserCart(userId)
|
cart = db3.getUserCart(userId)
|
||||||
products: seq[Products]
|
|
||||||
|
|
||||||
for c, d in cart:
|
for c, d in cart:
|
||||||
var product = db1.getProductById(d.productId)
|
var product = db1.getProductById(d.productId)
|
||||||
@ -171,13 +172,36 @@ import
|
|||||||
compileTemplateFile(getScriptDir() / "a3a" / "shop.nimja")
|
compileTemplateFile(getScriptDir() / "a3a" / "shop.nimja")
|
||||||
|
|
||||||
"/shop-single" -> get:
|
"/shop-single" -> get:
|
||||||
|
|
||||||
var
|
var
|
||||||
|
email: string
|
||||||
|
password: string
|
||||||
|
db2 = newDatabase2()
|
||||||
|
db3 = newDatabase3()
|
||||||
db1 = newDatabase1()
|
db1 = newDatabase1()
|
||||||
|
|
||||||
productName = ctx.queryParams["prod"]
|
productName = ctx.queryParams["prod"]
|
||||||
|
|
||||||
product = db1.getProduct(productName)
|
product = db1.getProduct(productName)
|
||||||
|
|
||||||
|
products: seq[Products]
|
||||||
|
|
||||||
|
try:
|
||||||
|
email = ctx.cookies["email"]
|
||||||
|
password = ctx.cookies["password"]
|
||||||
|
except:
|
||||||
|
email = ""
|
||||||
|
password = ""
|
||||||
|
|
||||||
|
if email != "" and password != "":
|
||||||
|
var
|
||||||
|
userId = db2.getUserId(email, password)
|
||||||
|
cart = db3.getUserCart(userId)
|
||||||
|
|
||||||
|
for c, d in cart:
|
||||||
|
var product1 = db1.getProductById(d.productId)
|
||||||
|
products.add(product1)
|
||||||
|
|
||||||
compileTemplateFile(getScriptDir() / "a3a" / "shop-single.nimja")
|
compileTemplateFile(getScriptDir() / "a3a" / "shop-single.nimja")
|
||||||
|
|
||||||
"/thankyou" -> get:
|
"/thankyou" -> get:
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="/cart" class="site-cart">
|
<a href="/cart" class="site-cart">
|
||||||
<span class="icon icon-shopping_cart"></span>
|
<span class="icon icon-shopping_cart"></span>
|
||||||
<span class="count">2</span>
|
{% if products.len > 0 %}
|
||||||
|
<span class="count">{{products.len}}</span>
|
||||||
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="d-inline-block d-md-none ml-md-0"><a href="#" class="site-menu-toggle js-menu-toggle"><span class="icon-menu"></span></a></li>
|
<li class="d-inline-block d-md-none ml-md-0"><a href="#" class="site-menu-toggle js-menu-toggle"><span class="icon-menu"></span></a></li>
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="/cart" class="site-cart">
|
<a href="/cart" class="site-cart">
|
||||||
<span class="icon icon-shopping_cart"></span>
|
<span class="icon icon-shopping_cart"></span>
|
||||||
<span class="count">2</span>
|
{% if products.len > 0 %}
|
||||||
|
<span class="count">{{products.len}}</span>
|
||||||
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="d-inline-block d-md-none ml-md-0"><a href="#" class="site-menu-toggle js-menu-toggle"><span class="icon-menu"></span></a></li>
|
<li class="d-inline-block d-md-none ml-md-0"><a href="#" class="site-menu-toggle js-menu-toggle"><span class="icon-menu"></span></a></li>
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="/cart" class="site-cart">
|
<a href="/cart" class="site-cart">
|
||||||
<span class="icon icon-shopping_cart"></span>
|
<span class="icon icon-shopping_cart"></span>
|
||||||
<span class="count">2</span>
|
{% if products.len > 0 %}
|
||||||
|
<span class="count">{{products.len}}</span>
|
||||||
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="d-inline-block d-md-none ml-md-0"><a href="#" class="site-menu-toggle js-menu-toggle"><span class="icon-menu"></span></a></li>
|
<li class="d-inline-block d-md-none ml-md-0"><a href="#" class="site-menu-toggle js-menu-toggle"><span class="icon-menu"></span></a></li>
|
||||||
|
Loading…
Reference in New Issue
Block a user