Rammohan0504 commited on
Commit
1cefdd1
·
verified ·
1 Parent(s): 786415e

Update templates/cart.html

Browse files
Files changed (1) hide show
  1. templates/cart.html +58 -21
templates/cart.html CHANGED
@@ -81,8 +81,10 @@
81
  margin-top: 20px;
82
  text-align: right;
83
  }
84
- .apply-coupon select, .apply-coupon button {
85
- font-size: 1rem;
 
 
86
  }
87
  .apply-coupon button {
88
  background-color: #28a745;
@@ -90,6 +92,7 @@
90
  padding: 5px 15px;
91
  border: none;
92
  cursor: pointer;
 
93
  }
94
  .apply-coupon button:hover {
95
  background-color: #218838;
@@ -99,6 +102,37 @@
99
  font-size: 1rem;
100
  color: red;
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  </style>
103
  </head>
104
  <body>
@@ -146,12 +180,7 @@
146
  <!-- Apply Coupon Section -->
147
  <div class="apply-coupon">
148
  <label for="coupon-code">Coupon Code:</label>
149
- <select id="coupon-code" name="coupon_code">
150
- <option value="">Select a coupon code</option>
151
- {% for coupon in coupon_codes %}
152
- <option value="{{ coupon.Coupon_Code__c }}">{{ coupon.Coupon_Code__c }}</option>
153
- {% endfor %}
154
- </select>
155
  <button type="button" onclick="applyCoupon()">Apply Coupon</button>
156
  <p id="coupon-message" class="coupon-message"></p>
157
  </div>
@@ -162,32 +191,40 @@
162
  <button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
163
  </div>
164
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  </div>
166
 
167
  <script>
168
- // Fetch coupon codes automatically when the page loads
169
  document.addEventListener("DOMContentLoaded", function() {
170
  const customerEmail = "{{ customer_email }}"; // The email stored in the session
171
 
172
  if (customerEmail) {
173
- fetch(`/get_coupon_codes?email=${customerEmail}`)
174
  .then(response => response.json())
175
  .then(data => {
176
- if (data.success && data.coupon_codes) {
177
- const couponSelect = document.getElementById('coupon-code');
178
- data.coupon_codes.forEach(coupon => {
179
- const option = document.createElement('option');
180
- option.value = coupon.Coupon_Code__c;
181
- option.textContent = coupon.Coupon_Code__c;
182
- couponSelect.appendChild(option);
183
- });
184
  } else {
185
- document.getElementById('coupon-message').innerText = "No active coupons found for your account.";
186
  document.getElementById('coupon-message').style.color = "red";
187
  }
188
  })
189
  .catch(error => {
190
- console.error('Error fetching coupon codes:', error);
191
  });
192
  }
193
  });
@@ -226,7 +263,7 @@
226
  couponMessage.style.color = 'red';
227
  });
228
  } else {
229
- couponMessage.innerText = 'Please select a coupon code.';
230
  couponMessage.style.color = 'red';
231
  }
232
  }
 
81
  margin-top: 20px;
82
  text-align: right;
83
  }
84
+ .apply-coupon input {
85
+ width: 200px;
86
+ padding: 5px;
87
+ margin-right: 10px;
88
  }
89
  .apply-coupon button {
90
  background-color: #28a745;
 
92
  padding: 5px 15px;
93
  border: none;
94
  cursor: pointer;
95
+ font-size: 1rem;
96
  }
97
  .apply-coupon button:hover {
98
  background-color: #218838;
 
102
  font-size: 1rem;
103
  color: red;
104
  }
105
+ .suggestion-section {
106
+ margin-top: 20px;
107
+ padding: 15px;
108
+ background-color: #f8f9fa;
109
+ border-radius: 10px;
110
+ }
111
+ .suggestion-item {
112
+ display: flex;
113
+ align-items: center;
114
+ justify-content: space-between;
115
+ padding: 10px 0;
116
+ }
117
+ .suggestion-item img {
118
+ width: 50px;
119
+ height: 50px;
120
+ object-fit: cover;
121
+ border-radius: 5px;
122
+ }
123
+ .add-back-button {
124
+ padding: 5px 15px;
125
+ font-size: 0.9rem;
126
+ border-radius: 20px;
127
+ border: 1px solid #007bff;
128
+ color: #007bff;
129
+ background-color: #fff;
130
+ cursor: pointer;
131
+ }
132
+ .add-back-button:hover {
133
+ background-color: #007bff;
134
+ color: #fff;
135
+ }
136
  </style>
137
  </head>
138
  <body>
 
180
  <!-- Apply Coupon Section -->
181
  <div class="apply-coupon">
182
  <label for="coupon-code">Coupon Code:</label>
183
+ <input type="text" id="coupon-code" name="coupon_code" placeholder="Coupon code will appear here" readonly>
 
 
 
 
 
184
  <button type="button" onclick="applyCoupon()">Apply Coupon</button>
185
  <p id="coupon-message" class="coupon-message"></p>
186
  </div>
 
191
  <button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
192
  </div>
193
  </div>
194
+
195
+ <!-- Suggestions Section -->
196
+ <div class="suggestion-section">
197
+ {% for suggestion in suggestions %}
198
+ <div class="suggestion-item">
199
+ <img src="{{ suggestion.Image1__c }}" alt="{{ suggestion.Name }}" onerror="this.src='/static/placeholder.jpg';">
200
+ <div>
201
+ <div>{{ suggestion.Name }}</div>
202
+ <div class="text-muted">${{ suggestion.Price__c }}</div>
203
+ </div>
204
+ <button class="add-back-button" onclick="addSuggestion('{{ suggestion.Id }}')">Add</button>
205
+ </div>
206
+ {% endfor %}
207
+ </div>
208
  </div>
209
 
210
  <script>
211
+ // Fetch coupon code automatically when the page loads
212
  document.addEventListener("DOMContentLoaded", function() {
213
  const customerEmail = "{{ customer_email }}"; // The email stored in the session
214
 
215
  if (customerEmail) {
216
+ fetch(`/get_coupon_code?email=${customerEmail}`)
217
  .then(response => response.json())
218
  .then(data => {
219
+ if (data.success && data.coupon_code) {
220
+ document.getElementById('coupon-code').value = data.coupon_code; // Set coupon code in the input
 
 
 
 
 
 
221
  } else {
222
+ document.getElementById('coupon-message').innerText = "No coupon found for your account.";
223
  document.getElementById('coupon-message').style.color = "red";
224
  }
225
  })
226
  .catch(error => {
227
+ console.error('Error fetching coupon code:', error);
228
  });
229
  }
230
  });
 
263
  couponMessage.style.color = 'red';
264
  });
265
  } else {
266
+ couponMessage.innerText = 'Please enter a coupon code.';
267
  couponMessage.style.color = 'red';
268
  }
269
  }