From 41f4d7ae2f773526bfe4f156d7b8a332826978d1 Mon Sep 17 00:00:00 2001
From: Michael Drury <mpdrury15@gmail.com>
Date: Fri, 28 Apr 2023 19:44:47 +0100
Subject: [PATCH] made alot better making it adjust with screen size

---
 instance/app.db              | Bin 20480 -> 20480 bytes
 shop/routes.py               |  22 ++++++++++++++++++++--
 shop/static/styles.css       |  21 ++++++++++++++++-----
 shop/templates/cart.html     |   5 ++++-
 shop/templates/checkout.html |   2 ++
 shop/templates/home.html     |   4 ++++
 6 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/instance/app.db b/instance/app.db
index 1775a1cbcfeb791982093819731bf24ba61b79be..968dc413020dedf200cf224ce8a0fc9128621f59 100644
GIT binary patch
delta 49
zcmZozz}T>Wae_3X=|mZ4M$?T6$7DtLyFiekLb@?hkT*9oIU_MOXYzVE(arvH8w~-1
ChY#`q

delta 49
zcmZozz}T>Wae_3X+(a2?M!Ag%$7DsM8zW`;yBI2fG_PQ8W^zViYR=^Ka-y64<u)1u
E0C?gLqyPW_

diff --git a/shop/routes.py b/shop/routes.py
index 28895b8..70b760a 100644
--- a/shop/routes.py
+++ b/shop/routes.py
@@ -126,10 +126,20 @@ def cart():
             for c in db.session.query(User).filter_by(id=current_user.get_id()):
                 c.cart = ''
             db.session.commit()
+        return redirect(url_for('cart'))
 
     total_price = get_total_cart_price()
 
-    return render_template('cart.html', cart_list = cart_list, cart_size = len(cart_list), total_price = total_price, remove_form = remove_form)
+    free_shipping = False
+    shipping_price = 4.99
+    if total_price >= 2000:
+        free_shipping = True
+    if free_shipping:
+        shipping_price = 0
+    final_price = shipping_price + total_price
+
+    return render_template('cart.html', cart_list = cart_list, cart_size = len(cart_list), total_price = total_price,
+                           remove_form = remove_form, shipping_price = shipping_price ,final_price = final_price)
 
 
 @app.route('/wishlist', methods=['GET', 'POST'])
@@ -208,7 +218,15 @@ def checkout():
     # gets the total price of items using the get_total_price function
     total_price = get_total_cart_price()
 
-    return render_template('checkout.html', total_price = total_price, form = form)
+    free_shipping = False
+    shipping_price = 4.99
+    if total_price >= 2000:
+        free_shipping = True
+    if free_shipping:
+        shipping_price = 0
+    final_price = shipping_price + total_price
+
+    return render_template('checkout.html', total_price = total_price, form = form, shipping_price = shipping_price ,final_price = final_price)
 
 
 def get_total_cart_price():
diff --git a/shop/static/styles.css b/shop/static/styles.css
index cd9d0da..795e0db 100644
--- a/shop/static/styles.css
+++ b/shop/static/styles.css
@@ -438,15 +438,16 @@ li {
 }
 
 .home_block {
-    padding-top: 10px;
-    padding-bottom: 10px;
+    padding-bottom: 20px;
+    position: relative;
 }
 
 .home_block_text {
-    top: 33%;
-    left: 50%;
     position: absolute;
+    top: 50%;
+    left: 50%;
     transform: translate(-50%, -50%);
+    text-align: center;
 }
 
 .start_shopping_text {
@@ -519,7 +520,7 @@ li {
 
 .header {
     background-color: #202020;
-    margin:0px;
+    margin: 0px;
     text-align: center;
     height: 80px;
 }
@@ -527,3 +528,13 @@ li {
 .header_img {
     height: 90%;
 }
+
+.discount_div {
+    background-color: lightgrey;
+    height: 50px;
+    font-size: 2vw;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    font-family: Andale Mono, monospace;
+}
\ No newline at end of file
diff --git a/shop/templates/cart.html b/shop/templates/cart.html
index d845789..cfb9109 100644
--- a/shop/templates/cart.html
+++ b/shop/templates/cart.html
@@ -42,9 +42,12 @@
     {% endif %}
 
     {% if cart_size > 0: %}
-        <p class = "total_price">Total price: £{{ total_price }}</p>
+    <p class = "total_price">Total price: £{{ total_price }}</p>
+    <p class = "total_price">Shipping price: £{{ shipping_price }}</p>
+    <p class = "total_price">Final price: £{{ final_price }}</p>
     {% endif %}
 
+
     {% for item in cart_list %}
         <div class = "cart_box" >
             <a href="/item?id={{item.product_id}}">
diff --git a/shop/templates/checkout.html b/shop/templates/checkout.html
index 1011c70..68ffb59 100644
--- a/shop/templates/checkout.html
+++ b/shop/templates/checkout.html
@@ -7,6 +7,8 @@
 <h1 class = "checkout_title">Checkout</h1>
 
 <p class = "checkout_price">Total to pay: £{{ total_price }}</p>
+<p class = "checkout_price">Shipping price: £{{ shipping_price }}</p>
+<p class = "checkout_price">Final price: £{{ final_price }}</p>
 
 
 <div class = "checkout_box">
diff --git a/shop/templates/home.html b/shop/templates/home.html
index 8e15874..8432961 100644
--- a/shop/templates/home.html
+++ b/shop/templates/home.html
@@ -17,6 +17,9 @@
 
     <p class = "slogan"><i>Ride with confidence, ride with quality parts</i></p>
 
+    <div class = "discount_div">
+        <p>Free shipping on all orders over £2000!</p>
+    </div>
     <div class = "home_block">
         <img class = "home_backround_image" src = "{{ url_for('static', filename='images/home_image1.jpg') }}" alt="backround image" style="width:100%;">
         <div class = "home_block_text">
@@ -25,6 +28,7 @@
             </a>
         </div>
     </div>
+
     <div class = "home_block">
         <img class = "home_backround_image" src = "{{ url_for('static', filename='images/home_image2.jpg') }}" alt="backround image" style="width:100%;">
     </div>
-- 
GitLab