Sometimes customer want to place links for currencies changing into his site header.php. Or smth another... But if to place link simply as: <a href="/?currency=USD">USD</a> - it will redirect user to the main page - what is not convenient. In such case JavaScript can help you!
- Drop links with the currencies you are need into the place you are need (header.php), example:
<a href="#" data-currency="USD" class="wpcs_currency_link">USD</a>
<a href="#" data-currency="EUR" class="wpcs_currency_link">EUR</a>
<a href="#" data-currency="GBP" class="wpcs_currency_link">GBP</a> - Somewhere in your theme.js or in the footer.php drop the next js code:12345jQuery(function () {jQuery('.wpcs_curr_link').click(function () {window.location.href = location.protocol + '//' + location.host + location.pathname + '?currency=' + jQuery(this).data('curr');});});
