Skip to main content

justJust a qucikquick update, i. I finished this by using regular expression, but.I still thinkingthink if we only just get only the JSON formmatedformatted data forfor the quote data from the controller thenthan that should be much more better for performance. thankThank you.

SolusionSolution:

require(['jquery', 'Magento_Customer/js/customer-data', 'jquery/jquery-storageapi'], function ($) { // $("#submitbutton").hide(); var spinner = $('.ajax-checkout-cart-loader'); var form = $('form#form-validate'); var qtyfields = $('#cart-getId() ?>-qty'); var changeDected = 0; $('.page.messages').each(function () { var thismessage = $(this); thismessage.attr('id', 'messages'); }); /* form.find(qtyfields).each(function (e) { var thisfield = $(this); //console.log(thisfield); $(this).change(function () { spinner.css("display", "block"); console.log('change detected'); form.submit(); }); }); */ form.on('submit', function (e) { e.preventDefault(); $.ajax({ url: form.attr('action'), data: form.serialize(), type: 'post', success: function (response) { var parsedResponse = $.parseHTML(response); var itemSubtotal = $(parsedResponse).find(".ajax-subtotal").text(); var itemSubtotalArray = itemSubtotal.split(" "); if(itemSubtotalArray.length !== 1) { itemSubtotalArray = itemSubtotalArray.filter(s => s.replace(/\s+/g, '').length !== 0); //console.log(itemSubtotalArray); } else { location.reload(); } //console.log(itemSubtotalArray.length); var ajaxSubtototal = $('.ajax-subtotal'); for (i=0; i

just a qucik update, i finished this by using regular expression, but still thinking if we only just get only the JSON formmated data for the quote data from the controller then that should be much more better. thank you

Solusion:

require(['jquery', 'Magento_Customer/js/customer-data', 'jquery/jquery-storageapi'], function ($) { // $("#submitbutton").hide(); var spinner = $('.ajax-checkout-cart-loader'); var form = $('form#form-validate'); var qtyfields = $('#cart-getId() ?>-qty'); var changeDected = 0; $('.page.messages').each(function () { var thismessage = $(this); thismessage.attr('id', 'messages'); }); /* form.find(qtyfields).each(function (e) { var thisfield = $(this); //console.log(thisfield); $(this).change(function () { spinner.css("display", "block"); console.log('change detected'); form.submit(); }); }); */ form.on('submit', function (e) { e.preventDefault(); $.ajax({ url: form.attr('action'), data: form.serialize(), type: 'post', success: function (response) { var parsedResponse = $.parseHTML(response); var itemSubtotal = $(parsedResponse).find(".ajax-subtotal").text(); var itemSubtotalArray = itemSubtotal.split(" "); if(itemSubtotalArray.length !== 1) { itemSubtotalArray = itemSubtotalArray.filter(s => s.replace(/\s+/g, '').length !== 0); //console.log(itemSubtotalArray); } else { location.reload(); } //console.log(itemSubtotalArray.length); var ajaxSubtototal = $('.ajax-subtotal'); for (i=0; i

Just a quick update. I finished this by using regular expression.I still think if we only get the JSON formatted data for the quote data from the controller than that should be better for performance. Thank you.

Solution:

require(['jquery', 'Magento_Customer/js/customer-data', 'jquery/jquery-storageapi'], function ($) { // $("#submitbutton").hide(); var spinner = $('.ajax-checkout-cart-loader'); var form = $('form#form-validate'); var qtyfields = $('#cart-getId() ?>-qty'); var changeDected = 0; $('.page.messages').each(function () { var thismessage = $(this); thismessage.attr('id', 'messages'); }); /* form.find(qtyfields).each(function (e) { var thisfield = $(this); //console.log(thisfield); $(this).change(function () { spinner.css("display", "block"); console.log('change detected'); form.submit(); }); }); */ form.on('submit', function (e) { e.preventDefault(); $.ajax({ url: form.attr('action'), data: form.serialize(), type: 'post', success: function (response) { var parsedResponse = $.parseHTML(response); var itemSubtotal = $(parsedResponse).find(".ajax-subtotal").text(); var itemSubtotalArray = itemSubtotal.split(" "); if(itemSubtotalArray.length !== 1) { itemSubtotalArray = itemSubtotalArray.filter(s => s.replace(/\s+/g, '').length !== 0); //console.log(itemSubtotalArray); } else { location.reload(); } //console.log(itemSubtotalArray.length); var ajaxSubtototal = $('.ajax-subtotal'); for (i=0; i
Source Link

just a qucik update, i finished this by using regular expression, but still thinking if we only just get only the JSON formmated data for the quote data from the controller then that should be much more better. thank you

Solusion:

require(['jquery', 'Magento_Customer/js/customer-data', 'jquery/jquery-storageapi'], function ($) { // $("#submitbutton").hide(); var spinner = $('.ajax-checkout-cart-loader'); var form = $('form#form-validate'); var qtyfields = $('#cart-getId() ?>-qty'); var changeDected = 0; $('.page.messages').each(function () { var thismessage = $(this); thismessage.attr('id', 'messages'); }); /* form.find(qtyfields).each(function (e) { var thisfield = $(this); //console.log(thisfield); $(this).change(function () { spinner.css("display", "block"); console.log('change detected'); form.submit(); }); }); */ form.on('submit', function (e) { e.preventDefault(); $.ajax({ url: form.attr('action'), data: form.serialize(), type: 'post', success: function (response) { var parsedResponse = $.parseHTML(response); var itemSubtotal = $(parsedResponse).find(".ajax-subtotal").text(); var itemSubtotalArray = itemSubtotal.split(" "); if(itemSubtotalArray.length !== 1) { itemSubtotalArray = itemSubtotalArray.filter(s => s.replace(/\s+/g, '').length !== 0); //console.log(itemSubtotalArray); } else { location.reload(); } //console.log(itemSubtotalArray.length); var ajaxSubtototal = $('.ajax-subtotal'); for (i=0; i