?action=wc_bulk_sku_changer_handle_upload") // But since it's id="wc-bulk-sku-changer-form", we'll handle it in JS if needed, but for now, assume standard submit. // Create js/admin.js file content (create this file in js folder) jQuery(document).ready(function($) { var urlParams = new URLSearchParams(window.location.search); if (urlParams.has('start_processing')) { $('#progress-bar').show(); $('#progress-message').text('Starting processing...'); processBatch(); } $('#wc-bulk-sku-changer-form').attr('action', 'https://nikplusco.com/wp-admin/admin-post.php?action=wc_bulk_sku_changer_handle_upload'); function processBatch() { $.ajax({ url: wc_bulk_sku_changer_ajax.ajax_url, type: 'POST', data: { action: 'wc_bulk_sku_changer_process_batch', nonce: wc_bulk_sku_changer_ajax.nonce }, success: function(response) { if (response.success) { if (response.data.complete) { $('#progress-message').text('Processing complete!'); displayReport(response.data.report); // Clean up URL history.replaceState(null, null, window.location.pathname + '?page=wc-bulk-sku-changer'); } else { $('.progress-bar').css('width', response.data.progress + '%').attr('aria-valuenow', response.data.progress); $('#progress-message').text('Processed: ' + response.data.processed + ' / ' + response.data.total + ' items'); setTimeout(processBatch, 1000); // Small delay to prevent server overload } } else { $('#progress-message').text('Error: ' + (response.data || 'Unknown error')); } }, error: function(xhr, status, error) { $('#progress-message').text('AJAX error: ' + error); } }); } function displayReport(report) { var html = '

Report

'; html += '

Success: ' + report.success + '

'; html += '

Failed: ' + report.failed + '

'; html += '

Skipped: ' + report.skipped + '

'; html += ''; $('#report').html(html); } $('#clear-logs').on('click', function(e) { e.preventDefault(); $.ajax({ url: wc_bulk_sku_changer_ajax.ajax_url, type: 'POST', data: { action: 'wc_bulk_sku_changer_clear_logs', nonce: wc_bulk_sku_changer_ajax.nonce }, success: function() { $('#logs').val(''); }, error: function() { alert('Failed to clear logs.'); } }); }); }); // Create css/admin.css (optional for progress bar styling) .progress { height: 20px; background-color: #f0f0f0; border-radius: 4px; overflow: hidden; } .progress-bar { height: 100%; background-color: #007cba; transition: width 0.3s ease-in-out; } موتور Archives - نیک پلاس
ورود | ثبت‌نام
نمایش فیلترها
سبد خرید

سبد خرید شما خالی است.

ورود به سایت