Follow

Content Item Vars for Multiple Currencies

Within Sailthru Content feeds, there are three currencies that are accepted: Euros, Dollars, and Pounds. However, there is the ability to show currency variations based on a user's location, in your templates. 

For example, if you had a Content Feed item, like the one below, you could assign vars for each currency. 

"content": [{"title": "Item Test","date": 1465230452,"vars": {"euros": 12,"dollars": 11,"pounds": 10},"url": "[http://example.com/mainsley/] (http://example.com/item/)","tags": ["item","currency"],"weight": 1,"sailthru": {"id": "5755xxxxxxxxxxxxxxxxxxxx","hash_id": "9777xxxxxxxxxxxxxxxxxxxxx"}}

Assigning these vars will allow you to show data to a user specifically in their currency. 

To display these currencies in a template you would use the following code, which will pull the var for each currency. 

{foreach content as c}
{c.title} costs:<br/>
In Euros: €{c.vars.euros}
<br/>
In Pounds: £{c.vars.pounds}
<br/>
In Dollars: ${c.vars.dollars}
<br/>
{/foreach}

So, with this example code, you will see all the currencies for the item.

Item Test costs:
In Euros: €12
In Pounds: £10
In Dollars: $11

You can then take the code one step further and add Zephyr Conditionals to only show the appropriate currency based on which country the user is in. The below examples are based on having a location var set on the user's profile. 

{if location=='US' then show ${c.vars.dollars}}
{else if location=='UK' then show £{c.vars.pounds}}
{else if location=='EU' then show €{c.vars.euros}}{/if}

This example code will show dollars for users you have a location var of US on their user profiles, or if that user is not based in the the US, it will show pounds for the UK or Euros for any European Union country (this 'EU' code is just high level and can be broken down on a per country basis).

 

Top