Hey,
Is it possible to make a kind of dropdown, where the customers of a webshop can choose his/her desired currency?
// Kasper
Developer forum
E-mail notifications
Changing currency inside shop
Kasper Jensen
Posted on 08/09/2011 14:14:50
Replies
Kristian Kirkholt
Posted on 14/09/2011 12:33:31
Hi Kasper
Not as standard. But this was done with heavy template building and some custom code on www.skovlarsen.dk
Normally you chose languge and are transferred to the correct currency on a specific language layer.
Not as standard. But this was done with heavy template building and some custom code on www.skovlarsen.dk
Normally you chose languge and are transferred to the correct currency on a specific language layer.
Casper Stendal
Posted on 05/01/2012 10:25:04
Nice solution exactly what we need.
It would be even more fantastic, if you would share the template with the dropdown? :)
Best regards
Casper Stendal
Posted on 05/01/2012 10:50:54
Should someone else have a solution for this problem, please drop a line...
It no problem to make the dropdown:
<select onchange="document.location='?currencycode=' + this.value;"> <option value="USD">USD: US Dollar</option> <option value="EUR">EUR: EU Euro</option> <option value="DKK">DKK: Danke Kroner</option> </select>
But how to get the current selected currency inside the template? So we can keep the right selection in the dropdown?
Casper Stendal
Posted on 05/01/2012 15:43:20
This post has been marked as an answer
Working solution:
<select id="selCurrency" onchange="updateCurrency(this.value)"> <option value="USD">USD: US Dollar</option> <option value="EUR">EUR: EU Euro</option> <option value="DKK">DKK: Danke Kroner</option> </select> <script type="text/javascript"> var selCurrency = document.getElementById('selCurrency'); for (var i = 0; i < selCurrency.options.length; i++) { if (selCurrency.options[i].value == getCookie('currencycode')) selCurrency.options[i].selected = true; } function updateCurrency(currency) { var url = document.location.href.replace(/¤cycode=.{3}/, '').replace(/\?currencycode=.{3}&/, '?').replace(/\?currencycode=.{3}/, ''); setCookie('currencycode', currency, 14); var parm = "?"; if (url.indexOf('?') >= 0) parm = "&"; document.location = url + parm + 'currencycode=' + currency; } function getCookie(c_name) { var i, x, y, ARRcookies = document.cookie.split(";"); for (i = 0; i < ARRcookies.length; i++) { x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); x = x.replace(/^\s+|\s+$/g, ""); if (x == c_name) { return unescape(y); } } } function setCookie(c_name, value, exdays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString()); document.cookie = c_name + "=" + c_value; } </script>
Votes for this answer: 1
You must be logged in to post in the forum