adding policy

This commit is contained in:
Flatlogic Bot 2026-04-22 04:55:52 +00:00
parent 69f39cc9cd
commit 56dfdabd5b
3 changed files with 55 additions and 0 deletions

View File

@ -17,11 +17,16 @@ $name = trim($input['name'] ?? '');
$phoneInput = trim($input['phone'] ?? ''); $phoneInput = trim($input['phone'] ?? '');
$phone = normalize_oman_phone($phoneInput); $phone = normalize_oman_phone($phoneInput);
$address = trim($input['address'] ?? ''); $address = trim($input['address'] ?? '');
$acceptPolicies = !empty($input['accept_policies']);
$paymentMethod = trim((string) ($input['payment_method'] ?? 'pay_later')); $paymentMethod = trim((string) ($input['payment_method'] ?? 'pay_later'));
if (!in_array($paymentMethod, ['pay_later', 'pay_online'], true)) { if (!in_array($paymentMethod, ['pay_later', 'pay_online'], true)) {
echo json_encode(['success' => false, 'error' => 'Invalid payment method']); echo json_encode(['success' => false, 'error' => 'Invalid payment method']);
exit; exit;
} }
if (!$acceptPolicies) {
echo json_encode(['success' => false, 'error' => 'You must accept the Privacy Policy and Terms & Conditions']);
exit;
}
if ($paymentMethod === 'pay_online' && !thawani_is_configured()) { if ($paymentMethod === 'pay_online' && !thawani_is_configured()) {
echo json_encode(['success' => false, 'error' => 'Thawani payment is not configured']); echo json_encode(['success' => false, 'error' => 'Thawani payment is not configured']);
exit; exit;

View File

@ -259,6 +259,17 @@
<textarea class="form-control" name="terms_conditions_content" rows="12" placeholder="<?= h(tr('أدخل نص الشروط والأحكام هنا...', 'Enter the terms and conditions content here...')) ?>"><?= h(get_setting('terms_conditions_content')) ?></textarea> <textarea class="form-control" name="terms_conditions_content" rows="12" placeholder="<?= h(tr('أدخل نص الشروط والأحكام هنا...', 'Enter the terms and conditions content here...')) ?>"><?= h(get_setting('terms_conditions_content')) ?></textarea>
<div class="form-text"><?= h(tr('يظهر هذا النص في صفحة الشروط والأحكام العامة.', 'This content appears on the public Terms & Conditions page.')) ?></div> <div class="form-text"><?= h(tr('يظهر هذا النص في صفحة الشروط والأحكام العامة.', 'This content appears on the public Terms & Conditions page.')) ?></div>
</div> </div>
<div class="col-12">
<div class="settings-inline-save border rounded-4 bg-body-tertiary px-3 py-3 d-flex flex-column flex-md-row justify-content-between align-items-md-center gap-3">
<div>
<div class="fw-semibold"><?= h(tr('حفظ السياسات', 'Save policies')) ?></div>
<div class="small text-muted"><?= h(tr('يمكنك الحفظ من هنا أيضاً إذا كان زر التذييل خارج الشاشة.', 'You can also save from here if the footer action is outside the screen.')) ?></div>
</div>
<button type="submit" class="btn btn-primary px-4 align-self-md-start">
<i class="bi bi-save me-1"></i><?= h(tr('حفظ التغييرات', 'Save Changes')) ?>
</button>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -273,6 +284,35 @@
</div> </div>
<style> <style>
#settingsModal .modal-header,
#settingsModal .modal-footer {
position: sticky;
z-index: 3;
background: var(--bs-body-bg);
}
#settingsModal .modal-header {
top: 0;
border-bottom: 1px solid var(--bs-border-color);
}
#settingsModal .modal-footer {
bottom: 0;
border-top: 1px solid var(--bs-border-color);
box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.06);
}
#settingsModal .modal-body {
padding-bottom: 1.25rem;
}
#settingsModal .settings-inline-save {
position: sticky;
bottom: -0.5rem;
z-index: 2;
box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}
#wablasSettingsModal { #wablasSettingsModal {
overflow-y: auto; overflow-y: auto;
} }

View File

@ -292,6 +292,15 @@ body { background-color: #f8f9fa; }
<div class="form-text mt-2 text-warning"><?= h(tr('خيار الدفع أونلاين ظاهر لكن مفاتيح ثواني غير مكتملة في الإعدادات بعد.', 'Pay Online is visible, but the Thawani keys are not fully configured in Settings yet.')) ?></div> <div class="form-text mt-2 text-warning"><?= h(tr('خيار الدفع أونلاين ظاهر لكن مفاتيح ثواني غير مكتملة في الإعدادات بعد.', 'Pay Online is visible, but the Thawani keys are not fully configured in Settings yet.')) ?></div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="mb-2">
<div class="form-check bg-light rounded-4 p-3 border">
<input class="form-check-input" type="checkbox" id="acceptPolicies" required>
<label class="form-check-label small" for="acceptPolicies">
<?= tr('أوافق على <a href="privacy-policy.php" target="_blank" rel="noopener">سياسة الخصوصية</a> و<a href="terms-conditions.php" target="_blank" rel="noopener">الشروط والأحكام</a>.', 'I agree to the <a href="privacy-policy.php" target="_blank" rel="noopener">Privacy Policy</a> and <a href="terms-conditions.php" target="_blank" rel="noopener">Terms &amp; Conditions</a>.') ?>
</label>
</div>
<div class="form-text"><?= h(tr('يجب قبول السياسة والشروط قبل إرسال الطلب.', 'You must accept the policy and terms before placing the order.')) ?></div>
</div>
</form> </form>
</div> </div>
<div class="modal-footer border-top-0 pt-0 pb-4 px-4 d-flex justify-content-between"> <div class="modal-footer border-top-0 pt-0 pb-4 px-4 d-flex justify-content-between">
@ -431,6 +440,7 @@ async function submitOrder() {
phone: document.getElementById('customerPhone').value, phone: document.getElementById('customerPhone').value,
address: document.getElementById('customerAddress').value, address: document.getElementById('customerAddress').value,
payment_method: paymentMethodField.value, payment_method: paymentMethodField.value,
accept_policies: document.getElementById('acceptPolicies').checked,
items: cart items: cart
}; };