Documentation You are here: start » v » 2.0 » template_sets

This is an old revision of the document!


Template Sets

FoxyCart's template sets introduces the ability to group different settings together into a set which you can switch between based on the requirements for your store. Initially this is restricted to just the language and locale for your store - but we'll be expanding on it moving forward to incorporate more aspects of a FoxyCart store.

Right now, the template sets feature adds native multilingual and multicurrency functionality to FoxyCart stores. They can be managed from the “Template Sets” section of your store's FoxyCart administration, found under the “Templates” column of the navigation.

Adding a Template Set

You can add a new template set by navigating to the “Template Sets” section and selecting “Add a new Template Set” in the “Select a template set” select option.

Template set code
This is the actual code sent as the template_set parameter to the cart.
Description
A descriptive name for this template set that will help you determine what it will be used for.
Language
This is the language file for this template set which will be used for all dialogs and messages seen by your store customers. You can customize all of these values on the “Language” section of your store's administration. If you would like to see more default supported languages, please let us know.
Locale
This is the locale for this template set. This setting will determine how FoxyCart formats your currency display and date/time format.

Your store will always have a default template set which can not be removed, and it's code and description is read-only. This template set forms the default language and locale that your store will have if no specific custom template set has been specified for the cart session.

Applying a template set

A template set can be applied to a cart in a number of ways - but at it's root, it's simply specified using the template_set cart parameter.

Within an add to cart

The template_set attribute is session-wide, and can be applied simply with your existing add to carts:

<a href="http://YOURSTORE.foxycart.com/cart?name=My+Product&price=20&code=sku123&template_set=fr">Add My Product</a>
 
<form action="https://YOURSTORE.foxycart.com/cart" method="post">
    <input type="hidden" name="name" value="My Product" />
    <input type="hidden" name="price" value="20" />
    <input type="hidden" name="code" value="sku123" />
    <input type="hidden" name="template_set" value="fr" />
    <input type="submit" value="Add My Product" class="submit" />
</form>

As part of a language/currency selector

Commonly, when working with multilingual or mulitcurrency stores - you'll have some form of language or currency selection for customers on your website. You can perform a JSONP cart request in the background based on that selection to switch the cart's template set for the customers session:

<p>Select a language: <a class="foxy_lang" href="http://YOURSTORE.foxycart.com/cart?template_set=en">English</a> | <a class="foxy_lang"  href="http://YOURSTORE.foxycart.com/cart?template_set=fr">French</a> | <a class="foxy_lang"  href="http://YOURSTORE.foxycart.com/cart?template_set=de">German</a></p>
 
<script>
$(document).ready(function() {
    $(".foxy_lang").on("click", function() {
        FC.client.request($(this).attr("href"));
    });
});
</script>

Site Tools