diff --git a/03_WordPress/wp-content/plugins/ifnex-bridge/assets/css/ifnex-orders.css b/03_WordPress/wp-content/plugins/ifnex-bridge/assets/css/ifnex-orders.css index 67b918b..81b86fd 100644 --- a/03_WordPress/wp-content/plugins/ifnex-bridge/assets/css/ifnex-orders.css +++ b/03_WordPress/wp-content/plugins/ifnex-bridge/assets/css/ifnex-orders.css @@ -153,8 +153,8 @@ } .ifnex-step.active { color: var(--ifnex-primary-dark); font-weight: 700; } -.ifnex-form-step { display: none; } -.ifnex-form-step.active { display: block; animation: ifnexFadeIn 0.3s; } +.ifnex-form-step { display: none !important; } +.ifnex-form-step.active { display: block !important; } @keyframes ifnexFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } } .ifnex-form-card { @@ -374,14 +374,14 @@ /* ═══ Modern Customer Dashboard (ifnx) ═══ */ .ifnx-dashboard { - display: flex; gap: 24px; max-width: 1240px; margin: 0 auto; padding: 24px 0; + display: flex !important; gap: 24px; max-width: 1240px; margin: 0 auto; padding: 24px 0; font-family: inherit; } /* ── Sidebar ─ */ .ifnx-sidebar { - width: 260px; flex-shrink: 0; align-self: flex-start; - background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%); + width: 260px !important; flex-shrink: 0 !important; align-self: flex-start !important; + background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%) !important; border-radius: 20px; overflow: hidden; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25); } @@ -395,7 +395,7 @@ .ifnx-user-name { color: #fff; font-weight: 700; font-size: 16px; } .ifnx-user-email { color: rgba(255,255,255,0.55); font-size: 12px; margin-top: 4px; direction: ltr; } -.ifnx-menu { padding: 12px 0; display: flex; flex-direction: column; } +.ifnx-menu { padding: 12px 0; display: flex !important; flex-direction: column !important; } .ifnx-menu-item { display: flex; align-items: center; gap: 12px; padding: 13px 22px; color: rgba(255,255,255,0.72); diff --git a/03_WordPress/wp-content/plugins/ifnex-bridge/assets/js/ifnex-order-form.js b/03_WordPress/wp-content/plugins/ifnex-bridge/assets/js/ifnex-order-form.js index b7fcca3..1154b2e 100644 --- a/03_WordPress/wp-content/plugins/ifnex-bridge/assets/js/ifnex-order-form.js +++ b/03_WordPress/wp-content/plugins/ifnex-bridge/assets/js/ifnex-order-form.js @@ -10,20 +10,38 @@ jQuery(document).ready(function($) { // ─── Load Countries ─── function loadCountries() { + if (!ifnex_ajax || !ifnex_ajax.ajax_url) { + console.error('IFNEX: ifnex_ajax is not defined'); + showFormError('خطا در تنظیمات پلاگین. لطفاً صفحه را دوباره بارگذاری کنید.'); + return; + } + $.ajax({ url: ifnex_ajax.ajax_url, method: 'POST', data: { action: 'ifnex_get_countries', nonce: ifnex_ajax.nonce }, success: function(res) { - if (res.success) { + if (res.success && res.data && res.data.length > 0) { countries = res.data; populateCountrySelects(); + // Auto-select Iran based on default direction + var iran = countries.find(function(c) { return c.iso_code === 'IR'; }); + if (iran) { + var dir = $('#ifnex-direction').val(); + if (dir === 'export') { + $('#ifnex-from-country').val(iran.id).trigger('change'); + } else if (dir === 'import') { + $('#ifnex-to-country').val(iran.id).trigger('change'); + } + } } else { console.error('IFNEX: Failed to load countries', res); + showFormError('خطا در دریافت لیست کشورها. لطفاً صفحه را دوباره بارگذاری کنید.'); } }, error: function(xhr) { console.error('IFNEX: AJAX error loading countries', xhr.status); + showFormError('خطا در ارتباط با سرور. لطفاً اینترنت خود را بررسی کنید.'); } }); } @@ -166,26 +184,26 @@ jQuery(document).ready(function($) { // وزن واقعی html += '
'; - html += ''; - html += ''; + html += ''; + html += ''; html += '
'; // ابعاد html += '
'; - html += ''; - html += ''; + html += ''; + html += ''; html += '
'; // وزن حجمی (محاسبه خودکار - فقط نمایش) html += '
'; - html += ''; - html += ''; + html += ''; + html += ''; html += '
'; // توضیحات html += '
'; - html += ''; - html += ''; + html += ''; + html += ''; html += '
'; html += ''; @@ -327,32 +345,32 @@ jQuery(document).ready(function($) { // توضیحات html += '
'; - html += ''; - html += ''; + html += ''; + html += ''; html += '
'; // HS Code html += '
'; - html += ''; - html += ''; + html += ''; + html += ''; html += '
'; // تعداد html += '
'; - html += ''; - html += ''; + html += ''; + html += ''; html += '
'; // قیمت واحد html += '
'; - html += ''; - html += ''; + html += ''; + html += ''; html += '
'; // مجموع (محاسبه خودکار) html += '
'; html += ''; - html += ''; + html += ''; html += '
'; html += ''; @@ -448,15 +466,15 @@ jQuery(document).ready(function($) { function updateInvoiceStepVisibility() { var type = $('#ifnex-type').val(); if (type === 'PARCEL') { - $('.ifnex-step-invoice').show(); - $('.ifnex-step-invoice-content').show(); + $('.ifnex-step-invoice').css('display', ''); + $('.ifnex-step-invoice-content').each(function() { this.style.setProperty('display', '', 'important'); }); // اگه اقلام خالی هست، یه قلم اولیه اضافه کن if (invoiceItems.length === 0) { addInvoiceItem(); } } else { - $('.ifnex-step-invoice').hide(); - $('.ifnex-step-invoice-content').hide(); + $('.ifnex-step-invoice').css('display', 'none'); + $('.ifnex-step-invoice-content').each(function() { this.style.setProperty('display', 'none', 'important'); }); // اگه کاربر توی Step 3 بود و نوع رو تغییر داد if (currentStep === 3) { goToStep(2); @@ -498,16 +516,24 @@ jQuery(document).ready(function($) { } // ─── Step Navigation ─── + // مراحل فرم خواهر هستند و فقط با کلاس active نمایش داده می‌شوند (CSS داخل ifnex-orders.css) function goToStep(step) { currentStep = step; - $('.ifnex-form-step').removeClass('active'); - $('.ifnex-form-step[data-step="' + step + '"]').addClass('active'); - $('.ifnex-step').each(function() { - var s = parseInt($(this).data('step')); - $(this).toggleClass('active', s === step); - $(this).toggleClass('done', s < step); + var $steps = $('#ifnex-order-form .ifnex-form-step'); + $steps.removeClass('active'); + $steps.filter('[data-step="' + step + '"]').addClass('active'); + + // به‌روزرسانی نشانگرهای پیشرفت بالای فرم + $('.ifnex-steps .ifnex-step').each(function() { + var s = parseInt($(this).attr('data-step'), 10); + $(this).removeClass('active done'); + if (s === step) $(this).addClass('active'); + else if (s < step) $(this).addClass('done'); }); - $('.ifnex-order-form-container')[0].scrollIntoView({ behavior: 'smooth' }); + + try { + document.querySelector('.ifnex-order-form-container').scrollIntoView({ behavior: 'smooth' }); + } catch(e) {} } $('.ifnex-next-step').on('click', function() { @@ -574,12 +600,15 @@ jQuery(document).ready(function($) { function validateStep2() { var ok = true; + var persianRegex = /[\u0600-\u06FF]/; ['#ifnex-sender-name', '#ifnex-sender-phone', '#ifnex-sender-city', '#ifnex-sender-address', '#ifnex-receiver-name', '#ifnex-receiver-phone', '#ifnex-receiver-city', '#ifnex-receiver-address'].forEach(function(sel) { - if (!$(sel).val()) { $(sel).css('border-color', '#ef4444'); ok = false; } + var val = $(sel).val(); + if (!val) { $(sel).css('border-color', '#ef4444'); ok = false; } + else if (persianRegex.test(val)) { $(sel).css('border-color', '#ef4444'); ok = false; } else { $(sel).css('border-color', ''); } }); - if (!ok) showFormError('لطفاً اطلاعات فرستنده و گیرنده را کامل کنید.'); + if (!ok) showFormError('لطفاً اطلاعات را به انگلیسی وارد کنید. آدرس و مشخصات باید به انگلیسی باشد.'); return ok; } @@ -599,7 +628,7 @@ jQuery(document).ready(function($) { if (res.success) { priceData = res.data; renderPriceSummary(res.data); - goToStep(4); + goToStep(5); } else { showCalcError(res.data || 'خطا در محاسبه قیمت'); } @@ -733,7 +762,7 @@ jQuery(document).ready(function($) { var orderId = res.data.data.id || res.data.id; // با فلوی جدید، کاربر به صفحه جزئیات سفارش هدایت می‌شود // (چون پرداخت فقط بعد از تأیید کارمند امکان‌پذیر است) - window.location.href = ifnex_ajax.orders_url + 'order-detail/?order_id=' + orderId; + window.location.href = ifnex_ajax.orders_url + '?tab=orders'; } else { $('#ifnex-submit-error').text(res.data || 'خطا در ثبت سفارش').show(); } @@ -745,13 +774,26 @@ jQuery(document).ready(function($) { }); }); + // ─── Auto-select Iran based on direction ─── + $('#ifnex-direction').on('change', function() { + var direction = $(this).val(); + if (!countries.length) return; + var iran = countries.find(function(c) { return c.iso_code === 'IR'; }); + if (!iran) return; + if (direction === 'export') { + $('#ifnex-from-country').val(iran.id).trigger('change'); + } else if (direction === 'import') { + $('#ifnex-to-country').val(iran.id).trigger('change'); + } + }); + // ─── Init ─── if ($('#ifnex-order-form').length) { - loadCountries(); - // افزودن بسته اول به‌صورت پیش‌فرض + // افزودن بسته اول به‌صورت پیش‌فرض (قبل از loadCountries تا اگه خطا داد، بسته باشه) addPackage(); // بررسی نوع محموله برای نمایش/مخفی‌کردن Step Invoice - // این تابع خودش اگه PARCEL باشه و اقلام خالی باشه، یه قلم اضافه می‌کنه updateInvoiceStepVisibility(); + // لود کشورها (اگه خطا داد اشکالی نداره) + try { loadCountries(); } catch(e) { console.error('IFNEX: loadCountries error', e); } } }); diff --git a/03_WordPress/wp-content/plugins/ifnex-bridge/ifnex-bridge.php b/03_WordPress/wp-content/plugins/ifnex-bridge/ifnex-bridge.php index 2fb5f32..a58f075 100644 --- a/03_WordPress/wp-content/plugins/ifnex-bridge/ifnex-bridge.php +++ b/03_WordPress/wp-content/plugins/ifnex-bridge/ifnex-bridge.php @@ -1,4 +1,7 @@ post_content, 'ifnex_tracking_form') || has_shortcode($post->post_content, 'ifnex_wallet_balance') || has_shortcode($post->post_content, 'ifnex_transactions') || - has_shortcode($post->post_content, 'ifnex_tracking_status'))) { - wp_enqueue_style('ifnex-bridge-css', plugin_dir_url(__FILE__) . 'assets/css/ifnex-bridge.css', array(), '1.0.0'); + has_shortcode($post->post_content, 'ifnex_tracking_status') || + has_shortcode($post->post_content, 'ifnex_order_form') || + has_shortcode($post->post_content, 'ifnex_user_profile') || + has_shortcode($post->post_content, 'ifnex_orders_list') || + has_shortcode($post->post_content, 'ifnex_order_detail') || + has_shortcode($post->post_content, 'ifnex_order_payment') || + has_shortcode($post->post_content, 'ifnex_customer_dashboard'))) { + wp_enqueue_style('ifnex-bridge-css', plugin_dir_url(__FILE__) . 'assets/css/ifnex-bridge.css', array('ifnex-main'), '2.0.0-' . time()); + wp_enqueue_script('ifnex-order-form-js', plugin_dir_url(__FILE__) . 'assets/js/ifnex-order-form.js', array('jquery'), '2.0.0-' . time(), true); } } diff --git a/03_WordPress/wp-content/plugins/ifnex-bridge/includes/api-client.php b/03_WordPress/wp-content/plugins/ifnex-bridge/includes/api-client.php index bd94bb4..681ec8e 100644 --- a/03_WordPress/wp-content/plugins/ifnex-bridge/includes/api-client.php +++ b/03_WordPress/wp-content/plugins/ifnex-bridge/includes/api-client.php @@ -1,4 +1,7 @@ 'رهگیری', ), $atts); + // خواندن پارامتر awb از URL + $awb_from_url = isset($_GET['awb']) ? sanitize_text_field($_GET['awb']) : ''; + ob_start(); ?>

- +
@@ -537,28 +543,29 @@ function ifnex_order_form_shortcode($atts) {

📦 مشخصات مرسوله

- -
- -
- - + +
- - + +
+

📦 بسته‌های مرسوله

@@ -602,17 +609,17 @@ function ifnex_order_form_shortcode($atts) {

👤 اطلاعات فرستنده

-
-
-
-
+
+
+
+

📮 اطلاعات گیرنده

-
-
-
-
+
+
+
+
@@ -661,7 +668,7 @@ function ifnex_order_form_shortcode($atts) {

🏷️ کد تخفیف (اختیاری)

-
+