// This will update the URL in the action link of the form to include the language subdirectory in the query string (e.g. locale=es) var updateFormLocale = function() { if (window.location.href.match(/cart/)) { // Check if on the cart page var language = Localize.getLanguage(); var forms = document.getElementsByTagName('form'); for (var i = 0; i < forms.length; i++) { if (forms[i].action.match(/cart/) && language) { // Update the form URL to include the language forms[i].action = '/cart?locale=' + language; } } } }; if (window.addEventListener) { window.addEventListener('load', updateFormLocale, false); } else if (window.attachEvent) { element.attachEvent('onload', updateFormLocale); } Localize.on('setLanguage', updateFormLocale);