Question

I have added one field for extra charges, depends on radio button selection in checkout page, its working with page refresh, but I want it to get data without page refresh.

Was it helpful?

Solution

I was solved that issue using below code.

jQuery( "#radio-button-id" ).change(function() {
    var id = this.id;
    require([
        'jquery',
        'Magento_Checkout/js/action/get-totals'
        ], function ($, getTotalsAction) {
        "use strict";

        $.ajax({
            method: "post",
            url: "<?php echo $baseUrl; ?>action/", //your ajax Url
            data: { id: id},
            dataType: "json",
            success: function (data) {
                var deferred = $.Deferred();
                getTotalsAction([], deferred);
            }
        });
    });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top