feat(order): add English address detection warning in order form
Implement a real-time language detection mechanism for sender and receiver address fields to warn users when they enter addresses exclusively in English. - Add JavaScript logic to detect non-Arabic/Persian characters in address inputs - Implement a warning UI component with specific styling for address alerts - Update order form shortcode to include warning containers - Increment CSS asset versions to ensure style updates are applied
This commit is contained in:
parent
c0a50acaef
commit
1c2ff9941e
@ -649,3 +649,18 @@
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── English Address Warning ── */
|
||||
.ifnex-address-warning {
|
||||
background: #fffbeb;
|
||||
color: #92400e;
|
||||
padding: 10px 14px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
margin-top: 6px;
|
||||
border: 1px solid #fde68a;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
animation: ifnexFadeIn 0.25s ease;
|
||||
}
|
||||
@ -193,6 +193,28 @@ jQuery(document).ready(function($) {
|
||||
});
|
||||
});
|
||||
|
||||
// ─── English Address Warning ───
|
||||
function isEnglishText(text) {
|
||||
var cleaned = text.replace(/[\s0-9\-.,،؛:()\/#]/g, '');
|
||||
return cleaned.length > 0 && !/[\u0600-\u06FF\u0750-\u077F\uFB50-\uFDFF\uFE70-\uFEFF]/.test(cleaned);
|
||||
}
|
||||
|
||||
function checkAddressLang(inputId, warningId) {
|
||||
var text = $(inputId).val();
|
||||
if (text && isEnglishText(text)) {
|
||||
$(warningId).slideDown(200);
|
||||
} else {
|
||||
$(warningId).slideUp(200);
|
||||
}
|
||||
}
|
||||
|
||||
$('#ifnex-sender-address').on('input', function() {
|
||||
checkAddressLang('#ifnex-sender-address', '#ifnex-sender-address-warning');
|
||||
});
|
||||
$('#ifnex-receiver-address').on('input', function() {
|
||||
checkAddressLang('#ifnex-receiver-address', '#ifnex-receiver-address-warning');
|
||||
});
|
||||
|
||||
// ─── Init ──
|
||||
if ($('#ifnex-order-form').length) {
|
||||
loadCountries();
|
||||
|
||||
@ -555,14 +555,25 @@ function ifnex_order_form_shortcode($atts) {
|
||||
<div class="ifnex-field"><label>نام و نام خانوادگی *</label><input type="text" id="ifnex-sender-name"></div>
|
||||
<div class="ifnex-field"><label>شماره تماس *</label><input type="tel" id="ifnex-sender-phone"></div>
|
||||
<div class="ifnex-field"><label>شهر</label><input type="text" id="ifnex-sender-city"></div>
|
||||
<div class="ifnex-field full"><label>آدرس کامل *</label><textarea id="ifnex-sender-address" rows="2"></textarea></div>
|
||||
<div class="ifnex-field full">
|
||||
<label>آدرس کامل *</label>
|
||||
<textarea id="ifnex-sender-address" rows="2"></textarea>
|
||||
<div class="ifnex-address-warning" id="ifnex-sender-address-warning" style="display:none;">
|
||||
⚠️ آدرس به زبان انگلیسی وارد شده. برای تحویل بهتر، آدرس فارسی نیز وارد کنید.
|
||||
</div>
|
||||
</div> </div>
|
||||
<h3 style="margin-top:24px;">📮 اطلاعات گیرنده</h3>
|
||||
<div class="ifnex-form-grid">
|
||||
<div class="ifnex-field"><label>نام و نام خانوادگی *</label><input type="text" id="ifnex-receiver-name"></div>
|
||||
<div class="ifnex-field"><label>شماره تماس *</label><input type="tel" id="ifnex-receiver-phone"></div>
|
||||
<div class="ifnex-field"><label>شهر</label><input type="text" id="ifnex-receiver-city"></div>
|
||||
<div class="ifnex-field full"><label>آدرس کامل *</label><textarea id="ifnex-receiver-address" rows="2"></textarea></div>
|
||||
<div class="ifnex-field full">
|
||||
<label>آدرس کامل *</label>
|
||||
<textarea id="ifnex-receiver-address" rows="2"></textarea>
|
||||
<div class="ifnex-address-warning" id="ifnex-receiver-address-warning" style="display:none;">
|
||||
⚠️ آدرس به زبان انگلیسی وارد شده. برای تحویل بهتر، آدرس فارسی نیز وارد کنید.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ifnex-form-nav">
|
||||
<button class="ifnex-btn ifnex-prev-step">→ قبلی</button>
|
||||
|
||||
@ -540,7 +540,7 @@ function ifnex_enqueue_payment_assets() {
|
||||
|
||||
if (has_shortcode($post->post_content, 'ifnex_order_payment')) {
|
||||
$plugin_url = plugin_dir_url(dirname(__FILE__));
|
||||
wp_enqueue_style('ifnex-orders-css', $plugin_url . 'assets/css/ifnex-orders.css', array(), '1.3.0');
|
||||
wp_enqueue_style('ifnex-orders-css', $plugin_url . 'assets/css/ifnex-orders.css', array(), '1.4.0');
|
||||
wp_enqueue_script('jquery');
|
||||
wp_localize_script('jquery', 'ifnex_ajax', array(
|
||||
'ajax_url' => admin_url('admin-ajax.php'),
|
||||
@ -565,7 +565,7 @@ function ifnex_enqueue_global_assets() {
|
||||
'ifnex-orders-css',
|
||||
$plugin_url . 'assets/css/ifnex-orders.css',
|
||||
array(),
|
||||
'1.5.0'
|
||||
'1.6.0'
|
||||
);
|
||||
|
||||
// لود jQuery
|
||||
|
||||
Loading…
Reference in New Issue
Block a user