FOX - Currency Switcher Professional for WooCommerce

How to create currency links without shortcode

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 need into the place you are need (header.php), example:
    <a href=”#” data-currency=”USD” class=”woocs_currency_link”>USD</a>
    <a href=”#” data-currency=”EUR” class=”woocs_currency_link”>EUR</a>
    <a href=”#” data-currency=”GBP” class=”woocs_currency_link”>GBP</a>
  • Somewhere in your theme.js or in the footer.php drop the next js code:
    jQuery(function () {
     jQuery('.woocs_currency_link').click(function () {
        window.location.href = location.protocol + '//' + location.host + location.pathname + '?currency=' + jQuery(this).data('currency');
     });
    });