Skip to content

Commit

Permalink
udpate template + update CartRemove
Browse files Browse the repository at this point in the history
  • Loading branch information
behshadrhp committed Nov 1, 2023
1 parent 3efe536 commit c882d9b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cart/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CartRemoveView(View):
def post(self, request, product_id):
cart = Cart(request)
product = get_object_or_404(Product, id=product_id)
cart.remove()
cart.remove(product)
return redirect('cart:cart_detail')


Expand Down
12 changes: 12 additions & 0 deletions static/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
document.addEventListener('DOMContentLoaded', function() {
var footer = document.querySelector('.footer');
window.addEventListener('scroll', function() {
if (window.innerHeight >= document.body.scrollHeight) {
footer.style.display = 'none';
} else if (window.scrollY >= document.body.scrollHeight - window.innerHeight) {
footer.style.display = 'block';
} else {
footer.style.display = 'none';
}
});
});
12 changes: 12 additions & 0 deletions static/style/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,15 @@
margin: 50px auto;
text-align: center;
}

.footer {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 10px;
z-index: 9999;
}

2 changes: 1 addition & 1 deletion templates/cart/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1 class="mb-4">Your Shopping Cart</h1>
<td class="d-flex align-items-center">
<div class="mr-3">
<a href="{{ product.get_absolute_url }}">
<img src="{% if product.cover %}{{ product.cover.url }}{% else %}{% static "img/product.jpeg" %}{% endif %}" style='width: 100px;border-radius: 10%;'>
<img src="{% if product.cover %}{{ product.cover.url }}{% else %}{% static "img/product.jpeg" %}{% endif %}" style='width: 100px;border-radius: 10%;margin-right: 20px;'>
</a>
</div>
<div>
Expand Down
1 change: 1 addition & 0 deletions templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
{% include 'footer.html' %}

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm" crossorigin="anonymous"></script>
<script src="{% static 'js/main.js' %}"></script>
</body>
</html>

0 comments on commit c882d9b

Please sign in to comment.