JezK
Edit File: baf-admin.js
jQuery(document).ready(function ($) { // Resend Email Manually $(document).on('click', '.baf-resend-btn', function () { if (!confirm('Are you sure you want to resend this email?')) { return; } var btn = $(this); if (btn.hasClass('sending')) { return; } btn.addClass('sending') .prop('disabled', true) .text('Sending...'); $.ajax({ url: baf_ajax.ajax_url, type: 'POST', data: { action: 'baf_resend_email', nonce: baf_ajax.resend_nonce, booking_id: btn.data('booking'), order_id: btn.data('order') }, success: function (response) { if (response.success) { btn.text('Sent ✓'); setTimeout(function () { location.reload(); }, 800); } else { alert(response.data || 'Something went wrong.'); btn.removeClass('sending') .prop('disabled', false) .text('Resend'); } }, error: function () { alert('AJAX error occurred.'); btn.removeClass('sending') .prop('disabled', false) .text('Resend'); } }); }); // Send Test Preveiw Email Template $('#baf-send-test-email').on('click', function () { const button = $(this); const result = $('#baf-test-result'); button.prop('disabled', true); result.text('Sending...'); $.post(baf_ajax.ajax_url, { action: 'baf_send_test_email', nonce: baf_ajax.test_nonce }, function (response) { button.prop('disabled', false); if (response.success) { result.css('color', 'green').text(response.data); } else { result.css('color', 'red').text(response.data); } }); }); });