DOCUMENTATION

Multi Currency Store

Everything you need to get up and running with our Multi Currency Store plugin!

Creating your own currency switcher widget

If the output of the currency switcher widget isn't what your after, or if you want to add a switcher in a non-widgetised part of your site, you can create your own currency switcher.

Using basic HTML syntax, you can create anything you want to handle the currency switching. The only thing you need to ensure is that the link that is clicked to select the currency points to the URL of the current page (so the user returns to the same place) with the parameter wmcs_set_currency added to it, with the value of the parameter being the currency code that will be switched to.

For example, if using an <a> tag to create the link, the HTML would be:

<a href="?wmcs_set_currency=USD">Change to USD</a>

The plugin watches all page requests for the wmcs_set_currency parameter and if found, it will change currency for the user to the currency set by the parameter (assuming the currency exists in your store).

Making your switcher more dynamic

Although you could create your switcher using only HTML, it doesn't making it very dynamic and the HTML would need to be changed manually every time your add or remove a currency.

To make your switcher a little more dynamic, we would need to add some PHP so that we can get the currencies in your store dynamically and create the switcher for the currencies currently in your store.

You can use the wmcs_get_store_currencies() function to get all the currencies currently in your store. You can then use the data that is returned from this function to create you switcher by looping through the values.

For example:

$currencies = wmcs_get_store_currencies();
foreach($currencies as $code => $name) {
    echo '<a href="?wmcs_set_currency=' . $code . '">' . $code . '</a>';
}

Using a combination of PHP and HTML will enable you to create any type of switcher that could you need.

Powered by Froala Editor