I’d like to ask how I could disable AJAX at the checkout page (where you enter shipping and billing information) and that instead of using AJAX to update the cart summary based on your location, it would update by doing a natural refresh.
Currently the cart summary would update itself without reloading the page whenever the user switches their location via shipping location. I’d like to remove that AJAX and just have the page reload with the updated information.
I’m not too sure what sort of codes or direction I should be pointing at but I’m ready to provide whatever details necessary. Just let me know! Thank you!!
All WooCommerce strings are properly localized with
wp_localize_script
so I would think you could correctly translate them by creating the appropriate .po/.mo file, but I confess to not having a lot of experience with translations. For reference: all available language packs are at Github and you might also want to read the documentation.Anyway, the checkout scripts are all in
checkout.js
. Like any script you can dequeue it viawp_dequeue_script()
as long as you know the handle.I had a similar issue, and instead of remove the entire script, i went to see when the event is created, and i found this.
After reading a little, i found that I will not be able to unbind because of the namespace, so i hooked up on the
on
event and since i can’t prevent default i stoped the propagation of the event.and these solved my problem.
If you follow the logic of checkout.js source code you will notice that these AJAX actions related to editing the billing|shipping addresses can be safely disabled by changing the checkout form’s class name.
Yes, I know, it’s that simple. So instead of
form.checkout
make itform.checkout1
where.checkout1
is just an imaginary class name (it doesn’t have to be real/existent).Here is a sample code that might help you understand what’s required:
Please note that this is a hack which it’s not documented. They may however change the checkout form functionality at any time so keep that in mind. I can confirm it works on WC 2.6.14 and probably in earlier versions too.
We had a similar problem: loaded checkout scripts at a quote list checkout. The scripts where loaded through another plugin again (WooCommerce Germanized).
Our solution is a more explicit one:
And than:
One way to not disable checkout.js.
First it is possible that checkout.min.js is loaded instead of checkout.js.
Then comment thoses 2 lines :
Then your checkout page will be ajax free!