-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder.html
More file actions
314 lines (269 loc) · 8.62 KB
/
Copy pathorder.html
File metadata and controls
314 lines (269 loc) · 8.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>إتمام الطلب</title>
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@600&display=swap" rel="stylesheet">
<style>
body{
font-family:'Cairo',sans-serif;
background: radial-gradient(circle at top,#0f0f1a,#050510,#000);
margin:0;
padding:0;
color:#fff;
}
.form-container{
max-width:420px;
margin:40px auto;
background: rgba(20,20,35,0.9);
padding:25px;
border-radius:18px;
box-shadow:0 0 25px #00f7ff55, 0 0 60px #ff00ff22;
border:1px solid rgba(0,247,255,0.3);
backdrop-filter: blur(10px);
}
h2{
text-align:center;
color:#00f7ff;
text-shadow:0 0 10px #00f7ff;
}
.product-img{
width:100%;
height:200px;
border-radius:12px;
object-fit:cover;
margin-bottom:10px;
border:1px solid #00f7ff33;
}
.product-name{
display: block;
width: fit-content;
margin:10px auto;
font-size:18px;
padding:8px 18px;
background:#fff;
border-radius:12px;
box-shadow:0 2px 10px rgba(0,0,0,0.15);
text-align:center;
}
/* Gradient للنص داخل span */
.product-name span{
background: linear-gradient(90deg,#00f7ff,#ff00ff,#00ff88,#00f7ff);
background-size: 300% 300%;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: gradientMove 4s ease infinite;
}
/* الحركة */
@keyframes gradientMove{
0%{background-position:0% 50%}
50%{background-position:100% 50%}
100%{background-position:0% 50%}
}
.price{
text-align:center;
color:#00ff88;
font-size:20px;
margin-bottom:10px;
}
label{
display:block;
margin-top:10px;
margin-bottom:5px;
font-size:13px;
color:#ffd000;
}
input,select{
width:100%;
padding:12px;
border-radius:8px;
border:1px solid #00f7ff55;
background: rgba(0,0,0,0.4);
color:#fff;
outline:none;
font-size:14px;
}
input:focus,select:focus{
border-color:#ff00ff;
box-shadow:0 0 10px #ff00ff;
}
button{
width:100%;
padding:15px;
margin-top:15px;
background: linear-gradient(45deg,#00f7ff,#ff00ff);
border:none;
color:#fff;
font-size:16px;
border-radius:10px;
cursor:pointer;
transition:0.3s;
}
button:hover{
transform:scale(1.05);
box-shadow:0 0 25px #00f7ff, 0 0 35px #ff00ff;
}
</style>
</head>
<body>
<div class="form-container">
<h2>🛒 إتمام الطلب📤</h2>
<img class="product-img" id="productImg" src="" alt="product">
<div class="product-name">
<span id="productName">...</span>
</div>
<div class="price">التوصيل جميع الولايات🚚</div>
<label>👤 الاسم الكامل</label>
<input type="text" id="name" required>
<label>📞 رقم الهاتف</label>
<input type="tel" id="phone" required>
<label>📍 الولاية</label>
<select id="state" required>
<option value="">اختر الولاية</option>
<option>أدرار</option><option>الشلف</option><option>الأغواط</option>
<option>أم البواقي</option><option>باتنة</option><option>بجاية</option>
<option>بسكرة</option><option>بشار</option><option>البليدة</option>
<option>البويرة</option><option>تمنراست</option><option>تبسة</option>
<option>تلمسان</option><option>تيارت</option><option>تيزي وزو</option>
<option>الجزائر</option><option>الجلفة</option><option>جيجل</option>
<option>سطيف</option><option>سعيدة</option><option>سكيكدة</option>
<option>سيدي بلعباس</option><option>عنابة</option><option>قالمة</option>
<option>قسنطينة</option><option>المدية</option><option>مستغانم</option>
<option>المسيلة</option><option>معسكر</option><option>ورقلة</option>
<option>وهران</option><option>غرداية</option><option>غليزان</option>
</select>
<label>🏠 العنوان</label>
<input type="text" id="address">
<button onclick="sendOrder()">🛃تأكيد الطلب الآن</button>
</div>
<script>
// 🔥 Dynamic Product Fetch & Order Submission
const params = new URLSearchParams(window.location.search);
const pNameParam = params.get("product");
// 🏷️ Display Name & Setup Default Image
const nameSpan = document.getElementById("productName");
nameSpan.innerText = pNameParam ? pNameParam : "منتج غير محدد";
const imgEl = document.getElementById("productImg");
imgEl.src = "product7.jpg"; // Default fallback
// Fetch current products from API to show the correct image
async function loadProductImage() {
try {
const response = await fetch('/api/products');
if (response.ok) {
const products = await response.json();
const matched = products.find(p => p.title === pNameParam);
if (matched) {
imgEl.src = matched.image;
} else if (products.length > 0) {
// Fallback to static mapping if not found
const staticMapping = {
"لوحة سيارة": "product 1.jpg",
"jont-Alliage": "product2.jpg",
"VL-M09": "product3.jpg",
"مظخم صوت": "product4.jpg",
"Sony Xplod": "product5.jpg",
"bass small": "product6.jpg",
"all": "product7.jpg",
"wipers": "product8.jpg",
"مكبر صوت silverton": "product9.jpg",
"POSTE Radio Sony": "product10.jpg",
"مكبر صوت ظخم": "product11.jpg",
"طقم تنظيف": "product12.jpg",
"السيارة حامل": "حامل سيارة.jpg",
"Auxilieur Cable": "product13.jpg",
"CYO (JM)": "product14.jpg",
"إكسسوار مكعبات": "product15.jpg",
"كودوار": "product16.jpg",
"مطفأة سجار": "product17.jpg",
"Covre De Vollon": "product18.jpg",
"Parfume X Lavandre": "product19.jpg",
"مصابيح LED": "product20.jpg",
"مطفأة حرائق": "FB_IMG_1777244221436.jpg",
"Far i10": "product22.jpg",
"Logan Alto": "product23.jpg",
"SYMBOL": "product24.jpg",
"Logan Avant": "product24.5.jpg",
"Feux Rouge": "product26_1753876563704.jpg"
};
if (staticMapping[pNameParam]) {
imgEl.src = staticMapping[pNameParam];
}
}
}
} catch (err) {
console.error("Failed to fetch product image:", err);
}
}
// 📤 Send Order
async function sendOrder() {
const name = document.getElementById("name").value.trim();
const phone = document.getElementById("phone").value.trim();
const state = document.getElementById("state").value.trim();
const address = document.getElementById("address").value.trim();
if (!name || !phone || !state) {
alert("يرجى ملء الاسم الكامل والهاتف والولاية ❌");
return;
}
const productName = pNameParam || "منتج غير محدد";
// 1. Submit to database API
try {
const response = await fetch('/api/orders', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
productName,
customerName: name,
customerPhone: phone,
state,
address
})
});
if (!response.ok) {
console.warn("API order submission returned error status");
}
} catch (err) {
console.error("Failed to submit order to API database:", err);
}
// 2. Keep client-side localStorage for offline backups
let localOrders = JSON.parse(localStorage.getItem("orders")) || [];
localOrders.push({
product: productName,
name: name,
phone: phone,
state: state,
address: address,
date: new Date().toLocaleString("ar-DZ"),
status: "جديد"
});
localStorage.setItem("orders", JSON.stringify(localOrders));
// 3. Format message & redirect to WhatsApp (with configured link if exists)
let whatsappBase = "https://wa.me/213795619382";
try {
const settingsResponse = await fetch('/api/settings');
if (settingsResponse.ok) {
const settings = await settingsResponse.json();
if (settings.whatsapp_link) {
whatsappBase = settings.whatsapp_link;
} else if (settings.phone2) {
whatsappBase = `https://wa.me/${settings.phone2.replace(/[\s+]/g, '')}`;
}
}
} catch (e) {
console.error("Failed to load settings in checkout:", e);
}
const msg = `🛒 طلب جديد:
👤 الاسم: ${name}
📞 الهاتف: ${phone}
📍 الولاية: ${state}
🏠 العنوان: ${address}
📦 المنتج: ${productName}`;
// Redirect client to whatsapp to complete flow
window.open(whatsappBase + "?text=" + encodeURIComponent(msg), "_blank");
}
window.addEventListener('DOMContentLoaded', loadProductImage);
</script>
</body>
</html>