File: /mnt/data/doccure-wp-market/wp-content/themes/doccure/assets/js/doccure-ajax.js
jQuery(document).ready(function ($) {
$(document).on('click', '.remove-doctor-btn', function (e) {
e.preventDefault();
const doctorId = $(this).data('doctor-id');
const button = $(this);
if (!doctorId) {
alert('Invalid doctor ID');
return;
}
$.ajax({
url: doccure_ajax_obj.ajax_url,
type: 'POST',
data: {
action: 'remove_saved_doctor',
doctor_id: doctorId,
security: doccure_ajax_obj.security,
},
success: function (response) {
if (response.success) {
alert(response.data.message);
button.closest('.profile-widget').remove(); // Remove the doctor from the DOM
location.reload();
} else {
alert(response.data.message);
}
},
error: function () {
alert('An error occurred. Please try again.');
},
complete: function () {
button.text('Remove');
},
});
});
});
jQuery(document).ready(function ($) {
$('.view-invoice').on('click', function () {
var orderId = $(this).data('order-id');
// AJAX request to fetch order details
$.ajax({
url: doccure_ajax_obj.ajax_url,
method: 'POST',
data: {
action: 'fetch_invoice_details',
order_id: orderId,
security: doccure_ajax_obj.security,
},
success: function (response) {
// $('#invoice-modal-body').html(response);
$('#invoice-modal-body').html(response.data);
$('#invoice_view').modal('show'); // Ensure the modal is visible
},
error: function () {
$('#invoice-modal-body').html('<p class="text-danger">Unable to load invoice details.</p>');
}
});
});
});