less than a minute read • Updated 8 minutes ago
Set up multicurrency with template sets
How to switch a customer's entire cart to a different currency and language using the template_set parameter.
The template_set parameter switches the currency (and optionally the language) for a customer's entire cart session. It's passed as the template set's code, for example &template_set=fr, and applies session-wide rather than to individual products.
How to set it up
https://yourdomain.foxycart.com/cart?name=Example&price=50mxn&code=a33938&template_set=mx
Set the currency silently on page load
To set the session's currency without sending the customer to the cart (for example, on page load or when they click a locale link), request the /cart endpoint in the background:
html
<a id="locale-mxn" href="javascript:;">Set locale to MXN in the background</a>
<script>
document.getElementById('locale-mxn').onclick = function(){
FC.client.request('https://' + FC.settings.storedomain + '/cart?template_set=mx')
.done(function(data){
console.log(data.locale_info.int_curr_symbol);
});
};
</script>Notes
Changing
template_setto one with a different locale than the cart is currently using will empty the cart. To avoid losing items, add the products in the same request that changes thetemplate_setand they'll be added in the correct currency.If you don't pass a
template_set, customers see your store's default locale (theDEFAULTtemplate set, or the store locale setting on your store's settings page).