php - how to apply the modified final cost on the checkout page via ajax?
one text
There is a task: to fasten the button on the checkout page by pressing which the discount for the total amount should be applied. Greetings to all! There is a task: to fasten the button on the checkout page by pressing which the discount for the total amount should be applied.
jQuery(document).ready(function($) {
$("#discount_btn").click(function() {
action = "setdiscount";
$.ajax({
type: "POST",
dataType: "json",
url: wc_checkout_params.ajax_url,
data: {
"action": action,
},
success: function(data) {
$(document.body).trigger("update_checkout");
console.log(data);
}
});
})
})
Source