Skip to main content
deleted 2 characters in body
Source Link

Have you tried deferred operation with getTotalsAction or totals-processor?

It's showing ajax process in your cart after calcul

you can use thisit like this (i minimize your code, just to show you how to use these functions.) :

require(["jquery", "Magento_Customer/js/customer-data","jquery/jquery-storageapi","Magento_Checkout/js/model/cart/totals-processor/default","Magento_Checkout/js/model/cart/cache","Magento_Checkout/js/model/quote","Magento_Checkout/js/action/get-totals"], function ($,defaultTotal,cartCache,quote,getTotalsAction) { $(document).on("submit","form#form-validate", function (e) { e.preventDefault(); $.ajax({ url: form.attr("action"), data: form.serialize(), type: "post", success: function (res) { var deferred = $.Deferred(); // this show ajax loader and reload price in cart getTotalsAction([], deferred); // this one too defaultTotal.estimateTotals(); }, error: function () { console.log("error"); } }); console.log("form submitted"); });}); 

I suggest you to show this post for updating price in cart : How to add fee to order totals in Magento 2 and this one : https://github.com/sivajik34/Custom-Fee-Magento2

Have you tried deferred operation with getTotalsAction or totals-processor?

It's showing ajax process in your cart after calcul

you can use this like this (i minimize your code, just to show you how to use these functions.) :

require(["jquery", "Magento_Customer/js/customer-data","jquery/jquery-storageapi","Magento_Checkout/js/model/cart/totals-processor/default","Magento_Checkout/js/model/cart/cache","Magento_Checkout/js/model/quote","Magento_Checkout/js/action/get-totals"], function ($,defaultTotal,cartCache,quote,getTotalsAction) { $(document).on("submit","form#form-validate", function (e) { e.preventDefault(); $.ajax({ url: form.attr("action"), data: form.serialize(), type: "post", success: function (res) { var deferred = $.Deferred(); // this show ajax loader and reload price in cart getTotalsAction([], deferred); // this one too defaultTotal.estimateTotals(); }, error: function () { console.log("error"); } }); console.log("form submitted"); });}); 

I suggest you to show this post for updating price in cart : How to add fee to order totals in Magento 2 and this one : https://github.com/sivajik34/Custom-Fee-Magento2

Have you tried deferred operation with getTotalsAction or totals-processor?

It's showing ajax process in your cart after calcul

you can use it like this (i minimize your code, just to show you how to use these functions.) :

require(["jquery", "Magento_Customer/js/customer-data","jquery/jquery-storageapi","Magento_Checkout/js/model/cart/totals-processor/default","Magento_Checkout/js/model/cart/cache","Magento_Checkout/js/model/quote","Magento_Checkout/js/action/get-totals"], function ($,defaultTotal,cartCache,quote,getTotalsAction) { $(document).on("submit","form#form-validate", function (e) { e.preventDefault(); $.ajax({ url: form.attr("action"), data: form.serialize(), type: "post", success: function (res) { var deferred = $.Deferred(); // this show ajax loader and reload price in cart getTotalsAction([], deferred); // this one too defaultTotal.estimateTotals(); }, error: function () { console.log("error"); } }); console.log("form submitted"); });}); 

I suggest you to show this post for updating price in cart : How to add fee to order totals in Magento 2 and this one : https://github.com/sivajik34/Custom-Fee-Magento2

deleted 1050 characters in body
Source Link

you can use this like this (I just inserted intoi minimize your code) :

require([ 'jquery', 'Magento_Customer/js/customer-data', 'jquery/jquery-storageapi', 'Magento_Checkout/js/model/cart/totals-processor/default', 'Magento_Checkout/js/model/cart/cache', 'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/action/get-totals'

], function ($,defaultTotal,cartCache,quote,getTotalsAction) { // $("#submitbutton").hide(); var form = $('form#form-validate'); var qtyfields = $('input.qty'); $('.page.messages').each(function () { var thismessage = $(this); thismessage just to show you how to use these functions.attr('id', 'messages'); }); :

form.find(qtyfields).each(function (e) { var thisfield = $require(this); ["jquery", "Magento_Customer/js/customer-data","jquery/jquery-storageapi","Magento_Checkout/js/model/cart/totals-processor/default","Magento_Checkout/js/model/cart/cache","Magento_Checkout/js/model/quote","Magento_Checkout/js/action/get-totals"], $(this).change(function ($,defaultTotal,cartCache,quote,getTotalsAction) {  console.log('change detected'); form.submit(); }); }); $(document).on('submit'"submit",'form#form"form#form-validate'validate", function (e) { var thisfield = $(this); var thisiteminfo = thisfield.closest(".item-info"); var thissubtotal = thisiteminfo.children(".subtotal");   var formsubtotals = $(this).find('.subtotal'); e.preventDefault(); $.ajax({ url: form.attr('action'"action"), data: form.serialize(), type: 'post'"post", success: function (res) {  var parsedResponse = $.parseHTML(res);   var result = $(parsedResponse).find("#form-validate"); $("#form-validate").replaceWith(result); var totals = $(parsedResponse).find("#cart-totals"); $("#cart-totals").replaceWith(totals); console.log(totals); //location.reload(); var deferred = $.Deferred(); // this show ajax loader and reload price in cart getTotalsAction([], deferred); // this one too defaultTotal.estimateTotals(); }, error: function () { console.log('error'"error"); } }); console.log('form"form submitted'submitted"); });});  

});

you can use this like this (I just inserted into your code) :

require([ 'jquery', 'Magento_Customer/js/customer-data', 'jquery/jquery-storageapi', 'Magento_Checkout/js/model/cart/totals-processor/default', 'Magento_Checkout/js/model/cart/cache', 'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/action/get-totals'

], function ($,defaultTotal,cartCache,quote,getTotalsAction) { // $("#submitbutton").hide(); var form = $('form#form-validate'); var qtyfields = $('input.qty'); $('.page.messages').each(function () { var thismessage = $(this); thismessage.attr('id', 'messages'); });

form.find(qtyfields).each(function (e) { var thisfield = $(this);  $(this).change(function () {  console.log('change detected'); form.submit(); }); }); $(document).on('submit','form#form-validate', function (e) { var thisfield = $(this); var thisiteminfo = thisfield.closest(".item-info"); var thissubtotal = thisiteminfo.children(".subtotal");   var formsubtotals = $(this).find('.subtotal'); e.preventDefault(); $.ajax({ url: form.attr('action'), data: form.serialize(), type: 'post', success: function (res) {  var parsedResponse = $.parseHTML(res);   var result = $(parsedResponse).find("#form-validate"); $("#form-validate").replaceWith(result); var totals = $(parsedResponse).find("#cart-totals"); $("#cart-totals").replaceWith(totals); console.log(totals); //location.reload(); var deferred = $.Deferred(); // this show ajax loader and reload price in cart getTotalsAction([], deferred); // this one too defaultTotal.estimateTotals(); }, error: function () { console.log('error'); } }); console.log('form submitted'); }); 

});

you can use this like this (i minimize your code, just to show you how to use these functions.) :

require(["jquery", "Magento_Customer/js/customer-data","jquery/jquery-storageapi","Magento_Checkout/js/model/cart/totals-processor/default","Magento_Checkout/js/model/cart/cache","Magento_Checkout/js/model/quote","Magento_Checkout/js/action/get-totals"], function ($,defaultTotal,cartCache,quote,getTotalsAction) { $(document).on("submit","form#form-validate", function (e) { e.preventDefault(); $.ajax({ url: form.attr("action"), data: form.serialize(), type: "post", success: function (res) { var deferred = $.Deferred(); // this show ajax loader and reload price in cart getTotalsAction([], deferred); // this one too defaultTotal.estimateTotals(); }, error: function () { console.log("error"); } }); console.log("form submitted"); });});  
Source Link

Have you tried deferred operation with getTotalsAction or totals-processor?

It's showing ajax process in your cart after calcul

you can use this like this (I just inserted into your code) :

require([ 'jquery', 'Magento_Customer/js/customer-data', 'jquery/jquery-storageapi', 'Magento_Checkout/js/model/cart/totals-processor/default', 'Magento_Checkout/js/model/cart/cache', 'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/action/get-totals'

], function ($,defaultTotal,cartCache,quote,getTotalsAction) { // $("#submitbutton").hide(); var form = $('form#form-validate'); var qtyfields = $('input.qty'); $('.page.messages').each(function () { var thismessage = $(this); thismessage.attr('id', 'messages'); });

form.find(qtyfields).each(function (e) { var thisfield = $(this); $(this).change(function () { console.log('change detected'); form.submit(); }); }); $(document).on('submit','form#form-validate', function (e) { var thisfield = $(this); var thisiteminfo = thisfield.closest(".item-info"); var thissubtotal = thisiteminfo.children(".subtotal"); var formsubtotals = $(this).find('.subtotal'); e.preventDefault(); $.ajax({ url: form.attr('action'), data: form.serialize(), type: 'post', success: function (res) { var parsedResponse = $.parseHTML(res); var result = $(parsedResponse).find("#form-validate"); $("#form-validate").replaceWith(result); var totals = $(parsedResponse).find("#cart-totals"); $("#cart-totals").replaceWith(totals); console.log(totals); //location.reload(); var deferred = $.Deferred(); // this show ajax loader and reload price in cart getTotalsAction([], deferred); // this one too defaultTotal.estimateTotals(); }, error: function () { console.log('error'); } }); console.log('form submitted'); }); 

});

I suggest you to show this post for updating price in cart : How to add fee to order totals in Magento 2 and this one : https://github.com/sivajik34/Custom-Fee-Magento2