File: /home/u665686179/domains/dealkr.com/public_html/public/assets/new/back-end/js/shipping-method.js
'use strict';
$(document).ready(function () {
let shippingTypeValue = $('input[name="shippingType"]:checked').val();
shippingType(shippingTypeValue);
});
$("#shipping-type-form").on('submit', function (event) {
event.preventDefault();
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
}
});
$.ajax({
url: $(this).attr('action'),
method: 'POST',
data: $(this).serialize(),
success: function (response) {
if (response?.status === 1) {
toastMagic.success(response?.message);
let shippingTypeValue = $('input[name="shippingType"]:checked').val();
shippingType(shippingTypeValue);
}
}
});
});
function shippingType(shippingTypeValue){
if (shippingTypeValue === 'category_wise') {
$('#product_wise_note').hide();
$('#order_wise_shipping').hide();
$('#update_category_shipping_cost').show();
} else if (shippingTypeValue === 'order_wise') {
$('#product_wise_note').hide();
$('#update_category_shipping_cost').hide();
$('#order_wise_shipping').show();
} else {
$('#update_category_shipping_cost').hide();
$('#order_wise_shipping').hide();
$('#product_wise_note').show();
}
}
function deleteDataWithoutForm() {
$(".delete-data").on("click", function () {
console.log("delete-data");
let getText = $("#order-wise-shipping-method-delete-content");
let dataFrom = $(this).data("from");
Swal.fire({
title: getText.data("sure"),
text: getText.data("text"),
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
cancelButtonText: getText.data("cancel"),
confirmButtonText: getText.data("confirm"),
reverseButtons: true,
}).then((result) => {
if (result.value) {
$.ajaxSetup({
headers: {
"X-CSRF-TOKEN": $('meta[name="_token"]').attr(
"content"
),
},
});
let id = $(this).data("id");
$.ajax({
url: $(this).data("action"),
method: "POST",
data: {id: id},
success: function (response) {
if (dataFrom == "currency") {
if (response.status == 1) {
toastMagic.success(
$("#get-delete-currency-message").data(
"success"
)
);
} else {
toastMagic.warning($("#get-delete-currency-message").data("warning"));
}
} else {
// toastMagic.success(
// $("#get-deleted-message").data("text")
// );
}
setTimeout(() => {
location.reload();
}, 2000);
},
});
}
});
});
}
deleteDataWithoutForm();