I have some jQuery/JavaScript that I use for language selection which will get the URL and then append the relevant language selection syntax to the end of it. Please see below:
jQuery/JavaScript:
jQuery(document).ready(function() {
var url = jQuery(location).attr('href') + '?___store=default&___from_store=default';
jQuery(".english").attr("href", (url));
});
HTML:
<div class="languageselection">
<table>
<tr>
<td><a class="english">English</a></td>
</tr>
</table>
</div>
This works great and does what I need it to, unless a user was to select a language and then try to move back to another language. This is because the ?___store=default&___from_store=default
is added twice onto the URL. Resulting in the following URL:
www.example.com/product.html?___store=default&___from_store=default?___store=default&___from_store=default
So my query is whether it's possible to amend my jQuery variable so that it only gets the URL up to the .html
point of the URL? This will result in the language syntax only ever being added once.
Thank you for any help.