028
This commit is contained in:
parent
3cc35531c4
commit
ab9f20f713
BIN
db5.sqlite3
BIN
db5.sqlite3
Binary file not shown.
42
src/a3.nim
42
src/a3.nim
@ -193,20 +193,19 @@ import
|
|||||||
email = ""
|
email = ""
|
||||||
password = ""
|
password = ""
|
||||||
|
|
||||||
if email == "":
|
try:
|
||||||
try:
|
productName = ctx.queryParams["prod"]
|
||||||
productName = ctx.queryParams["prod"]
|
quantity = parseInt(ctx.queryParams["quantity"])
|
||||||
quantity = parseInt(ctx.queryParams["quantity"])
|
except:
|
||||||
except:
|
productName = ""
|
||||||
productName = ""
|
quantity = 0
|
||||||
quantity = 0
|
|
||||||
|
|
||||||
if productName == "":
|
if productName == "":
|
||||||
ctx.redirect("/login")
|
ctx.redirect("/login")
|
||||||
|
|
||||||
price = db.getPriceByProductName(productName)
|
price = db.getPriceByProductName(productName)
|
||||||
|
|
||||||
else:
|
if email != "":
|
||||||
var
|
var
|
||||||
userId = db.getUserId(email, password)
|
userId = db.getUserId(email, password)
|
||||||
cart = db.getUserCart(userId)
|
cart = db.getUserCart(userId)
|
||||||
@ -227,6 +226,7 @@ import
|
|||||||
cart: seq[Cart]
|
cart: seq[Cart]
|
||||||
products: seq[Products]
|
products: seq[Products]
|
||||||
price = 0.0
|
price = 0.0
|
||||||
|
# cookies = ctx.cookies
|
||||||
|
|
||||||
try:
|
try:
|
||||||
email = ctx.cookies["email"]
|
email = ctx.cookies["email"]
|
||||||
@ -248,6 +248,16 @@ import
|
|||||||
|
|
||||||
price = db.getPriceByProductName(productName)
|
price = db.getPriceByProductName(productName)
|
||||||
|
|
||||||
|
# var
|
||||||
|
# country = cookies["c_country"]
|
||||||
|
# firstName = cookies["c_fname"]
|
||||||
|
# lastName = cookies["c_lname"]
|
||||||
|
# address = cookies["c_address"]
|
||||||
|
# state = cookies["c_state_country"]
|
||||||
|
# zip = cookies["c_postal_zip"]
|
||||||
|
# email = cookies["c_email_address"]
|
||||||
|
# phone = cookies["c_phone"]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
var
|
var
|
||||||
userId = db.getUserId(email, password)
|
userId = db.getUserId(email, password)
|
||||||
@ -378,12 +388,20 @@ import
|
|||||||
emailError = ""
|
emailError = ""
|
||||||
passwordError = ""
|
passwordError = ""
|
||||||
|
|
||||||
|
productName = ctx.queryParams["prod"]
|
||||||
|
quantity = parseInt(ctx.queryParams["quantity"])
|
||||||
|
|
||||||
if user == true:
|
if user == true:
|
||||||
|
|
||||||
ctx &= initCookie("email", email)
|
ctx &= initCookie("email", email)
|
||||||
ctx &= initCookie("password", password)
|
ctx &= initCookie("password", password)
|
||||||
|
|
||||||
ctx.redirect("/")
|
if quantity != 0:
|
||||||
|
ctx.redirect("/checkout?prod=" & productName & "&quantity=" & $quantity)
|
||||||
|
# ctx.redirect(fmt"/checkout?prod={productName}&quantity={quantity}")
|
||||||
|
else:
|
||||||
|
|
||||||
|
ctx.redirect("/")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
<div class="row mb-5">
|
<div class="row mb-5">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="border p-4 rounded" role="alert">
|
<div class="border p-4 rounded" role="alert">
|
||||||
Returning customer? <a href="/login">Click here</a> to login
|
Returning customer? <a href="/login?prod={{productName}}&quantity={{quantity}}" onclick="login()">Click here</a> to login
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -276,7 +276,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% var total = 0.0 %}
|
{% var total = 0.0 %}
|
||||||
{% if email == "" %}
|
{% if productName != "" %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{productName}} <strong class="mx-2">x</strong> {{quantity}}</td>
|
<td>{{productName}} <strong class="mx-2">x</strong> {{quantity}}</td>
|
||||||
<td>₹{{toFloat(quantity)*price}}</td>
|
<td>₹{{toFloat(quantity)*price}}</td>
|
||||||
@ -333,7 +333,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button class="btn btn-primary btn-lg py-3 btn-block" onclick="window.location='/thankyou'">Place Order</button>
|
<button class="btn btn-primary btn-lg py-3 btn-block" id="b3">Place Order</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -345,4 +345,33 @@
|
|||||||
<!-- </form> -->
|
<!-- </form> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
document.getElementById("b3").onclick = function() {
|
||||||
|
|
||||||
|
document.cookie = "c_country="+document.getElementById("c_country").value;
|
||||||
|
document.cookie = "c_fname="+document.getElementById("c_fname").value;
|
||||||
|
document.cookie = "c_lname="+document.getElementById("c_lname").value;
|
||||||
|
document.cookie = "c_address="+document.getElementById("c_address").value;
|
||||||
|
document.cookie = "c_state_country="+document.getElementById("c_state_country").value;
|
||||||
|
document.cookie = "c_postal_zip="+document.getElementById("c_postal_zip").value;
|
||||||
|
document.cookie = "c_email_address="+document.getElementById("c_email_address").value;
|
||||||
|
document.cookie = "c_phone="+document.getElementById("c_phone").value;
|
||||||
|
if (document.getElementById("c_create_account").checked) {
|
||||||
|
document.cookie = "c_create_account="+document.getElementById("c_create_account").value;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.href = '/thankyou';
|
||||||
|
}
|
||||||
|
|
||||||
|
function continueShopping() {
|
||||||
|
window.location.href = '/shop';
|
||||||
|
}
|
||||||
|
|
||||||
|
{# function login() {
|
||||||
|
var quantity = document.getElementById("quantity").value;
|
||||||
|
window.location.href = '/login'
|
||||||
|
+ '?prod={{productName}}&quantity='
|
||||||
|
+ quantity;
|
||||||
|
} #}
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user