diff --git a/instance/app.db b/instance/app.db index 1775a1cbcfeb791982093819731bf24ba61b79be..968dc413020dedf200cf224ce8a0fc9128621f59 100644 Binary files a/instance/app.db and b/instance/app.db differ diff --git a/shop/routes.py b/shop/routes.py index 28895b8c7b6c97e53103cae50a2ee9bf7433c679..70b760af83e39c80f6aea5613c63c3d385897b2f 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 cd9d0da333bb5d9518ec7d2992046a5efc87837a..795e0db1f8a3b19520ec8bd7ef0c6902bd0df51a 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 d845789b45f37cc098ec0213a2d3658cff754267..cfb910946514b8f68e036c8c3920b93c860bd9ef 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 1011c703d31a2d68e4459b6af581e59c1f069896..68ffb59b4ce1c85bdaedf5e2be705b22c47ec070 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 8e15874df175eef84d05ec7bf3192ae07bc13d9e..843296148f30c57f5bb5853cc54017d5c244920f 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>