diff --git a/shop/cart.py b/shop/cart.py index 9d8e720..154bc61 100644 --- a/shop/cart.py +++ b/shop/cart.py @@ -59,3 +59,12 @@ def clear_cart(request): """Clear the cart""" cart_id = get_or_create_cart_id(request) CartItem.objects.filter(session_id=cart_id).delete() + +# Add this function to your cart.py file +def get_cart_item(request, item_id): + """Get a specific cart item by its ID""" + cart_id = get_or_create_cart_id(request) + try: + return CartItem.objects.get(id=item_id, session_id=cart_id) + except CartItem.DoesNotExist: + raise Exception("Cart item not found") diff --git a/shop/forms.py b/shop/forms.py index c92b4db..a2f264b 100644 --- a/shop/forms.py +++ b/shop/forms.py @@ -2,4 +2,4 @@ from django import forms class GuestCheckoutForm(forms.Form): email = forms.EmailField(required=True) - phone = forms.CharField(max_length=20, required=True) + phone = forms.CharField(max_length=20, required=True, label="Téléphone portable") diff --git a/shop/static/shop/css/shop.css b/shop/static/shop/css/shop.css index 95e02d8..8fc4e4a 100644 --- a/shop/static/shop/css/shop.css +++ b/shop/static/shop/css/shop.css @@ -1,3 +1,4 @@ +/* Product Display */ .options-container { display: grid; grid-template-columns: 1fr 1fr 1fr; @@ -18,15 +19,16 @@ } .product-title { - font-size: 16px; /* Increase the font size for a bigger title */ - font-weight: bold; /* Make the title bold */ + font-size: 16px; + font-weight: bold; } .product-price { - font-size: 16px; /* Increase the font size for a bigger title */ - font-weight: bold; /* Make the title bold */ + font-size: 16px; + font-weight: bold; } +/* Grid Layout */ .option-element { align-content: center; } @@ -47,10 +49,12 @@ grid-column: 1; grid-row: 2; } + .option-element:nth-child(4) { grid-column: 2; grid-row: 2; } + .option-element:nth-child(5) { grid-column: 3; grid-row: 2; @@ -60,30 +64,38 @@ grid-column: 1 / span 2; grid-row: 3; } + .option-element:nth-child(7) { grid-column: 3; grid-row: 3; text-align: right; } +/* Buttons */ +.add-to-cart-button, +.checkout-button { + background-color: #90ee90; + color: #707070; + border: none; + border-radius: 12px; + font-size: 12px; + font-weight: 600; + text-decoration: none; + transition: background-color 0.3s ease; + cursor: pointer; +} + .add-to-cart-button { margin-top: 10px; width: 100%; - background-color: #90ee90; /* Green background */ text-align: center; display: inline-block; - height: 40px; /* Set the height to 40 pixels */ - transition: background-color 0.3s ease; /* Smooth transition on hover */ - color: #707070; - border-radius: 12px; - text-decoration: none; - font-size: 12px; - font-weight: 600; + height: 40px; } -.add-to-cart-button:hover { - background-color: #f39200; - color: white; +.checkout-button { + padding: 10px 20px; + display: inline-block; } .confirm-nav-button { @@ -95,12 +107,51 @@ color: white; } +.remove-btn { + background-color: #e84039; + color: white; + border: none; + padding: 5px 10px; + border-radius: 12px; + cursor: pointer; + font-size: 12px; + font-weight: 600; + transition: background-color 0.3s ease; +} + +.add-to-cart-button:hover, .confirm-nav-button:hover, -.cancel-nav-button:hover { - background-color: orange; +.cancel-nav-button:hover, +.remove-btn:hover { + background-color: #f39200; color: white; } +/* Cart Table */ +.cart-table { + width: 100%; + border-collapse: collapse; +} + +.cart-table th, +.cart-table td { + padding: 10px; + text-align: center; +} + +.text-left { + text-align: left !important; +} + +.price-column { + text-align: right; +} + +.cart-table thead, +.cart-table tfoot { + background-color: #f5f5f5; +} + .cart-table tbody tr.odd { background-color: #f0f0f0; } @@ -109,11 +160,6 @@ background-color: #e8e8e8; } -.cart-table th.price-column, -.cart-table td.price-column { - text-align: right; -} - .cart-table tfoot .total-label { font-weight: bold; } @@ -122,3 +168,143 @@ font-weight: bold; font-size: 1.2em; } + +/* Quantity Controls */ +.quantity-controls { + display: flex; + align-items: center; + justify-content: center; +} + +.quantity-form { + display: flex; + align-items: center; +} + +.quantity-btn { + width: 28px; + height: 28px; + border-radius: 50%; + border: 1px solid #ddd; + background-color: #f8f8f8; + cursor: pointer; + font-weight: bold; + display: flex; + align-items: center; + justify-content: center; + padding: 0; + margin: 0 3px; + font-size: 16px; + transition: background-color 0.3s ease; +} + +.quantity-btn:hover:not([disabled]) { + background-color: #f39200; + color: white; + border-color: #f39200; +} + +.quantity-btn:disabled { + opacity: 0.5; + cursor: not-allowed; +} + +.quantity-value { + margin: 0 5px; + min-width: 20px; + text-align: center; + font-weight: bold; + font-size: 14px; +} + +/* Cart Summary & Checkout */ +.cart-summary { + margin-top: 20px; + display: flex; + justify-content: space-between; + align-items: center; + flex-wrap: wrap; +} + +.guest-checkout-notice { + margin-top: 10px; + font-size: 0.9em; + background-color: #f8f9fa; + padding: 10px; + border-radius: 10px; + width: 100%; +} + +/* Checkout Page */ +.checkout-container { + padding: 25px; +} + +.checkout-section { + margin-bottom: 25px; +} + +.checkout-title { + color: #333; + font-size: 1.4em; + margin-bottom: 15px; + text-align: center; +} + +.checkout-description { + text-align: center; + margin-bottom: 20px; + color: #666; +} + +.guest-checkout-form { + background-color: #f8f9fa; + padding: 20px; + border-radius: 10px; + margin-bottom: 20px; +} + +.form-fields p { + margin-bottom: 15px; +} + +.form-fields label { + display: block; + margin-bottom: 5px; + font-weight: bold; +} + +.form-fields input { + width: 100%; + padding: 10px; + border: 1px solid #ddd; + border-radius: 8px; + font-size: 1em; +} + +.button-container { + display: flex; + justify-content: center; + margin-top: 20px; +} + +.checkout-options { + text-align: center; +} + +.checkout-options p { + margin: 15px 0; +} + +/* Links */ +.styled-link { + color: #f39200; + text-decoration: none; + font-weight: bold; + transition: color 0.3s; +} + +.styled-link:hover { + color: #e84039; + text-decoration: underline; +} diff --git a/shop/templates/shop/cart.html b/shop/templates/shop/cart.html index 8c0c971..f9717d2 100644 --- a/shop/templates/shop/cart.html +++ b/shop/templates/shop/cart.html @@ -25,47 +25,66 @@
| Produit | +Produit | Couleur | Taille | Quantité | Prix | +Actions | |||
|---|---|---|---|---|---|---|---|---|---|
| {{ item.product.title }} | +{{ item.product.title }} | {{ item.color.name }} | {{ item.size.name }} | -{{ item.quantity }} | +
+
+
+
+ |
{{ item.get_total_price }} € | ++ + | ||
| Total: | -{{ cart_items.total_quantity }} | +Total: | +{{ total_quantity }} | {{ total }} € | +|||||
Vous êtes déjà connecté en tant que {{ request.user.email }}.
- Passer à la commande +Vous êtes déjà connecté en tant que {{ request.user.email }}.
+ Passer à la commande +Vous n'êtes pas connecté. Veuillez choisir une option :
- - - -Ou connectez-vous si vous avez déjà un compte.
- -Pas encore de compte ? Créez-en un maintenant
+Vous n'êtes pas connecté. Veuillez choisir une option :
+| Produit | +Produit | Couleur | Taille | Quantité | @@ -37,7 +37,7 @@|||
|---|---|---|---|---|---|---|---|
| {{ item.product.title }} | +{{ item.product.title }} | {{ item.color.name|default:"N/A" }} | {{ item.size.name|default:"N/A" }} | {{ item.quantity }} | @@ -47,7 +47,7 @@|||
| Total: | +Total: | {{ order_items.count }} | {{ order.total_price }} € | ||||
| Produit | +Produit | Couleur | Taille | Quantité | @@ -40,7 +40,7 @@|||
|---|---|---|---|---|---|---|---|
| {{ item.product.title }} | +{{ item.product.title }} | {{ item.color.name|default:"N/A" }} | {{ item.size.name|default:"N/A" }} | {{ item.quantity }} | @@ -50,7 +50,7 @@|||
| Total: | +Total: | {{ order_items.count }} | {{ total }} € | ||||
Pas encore de compte ? Créer le tout de suite !
- {% for message in messages %} - - {% endfor %}