In this short guide, I will tell you how to use Spreadshirt's shop, country and currency data to format your prices correctly.
For formatting a price we need the following data:
- thousands separator . or , depending on the country
- decimal point -> , or . depending on the country
- currency symbol -> € or other depending on the currency
- price pattern -> currency symbol before or after price depending on the currency
- decimal count -> 1 or 2 decimal counts depending on the currency
Where do we get this data from? A shop, such as shop 205909, is actually configured for a specific country and currency. A sample payload is illustrated below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<shop xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://api.spreadshirt.net"
xlink:href="http://api.spreadshirt.net/api/v1/shops/205909" id="205909">
<user xlink:href="http://api.spreadshirt.net/api/v1/users/40000" id="40000"/>
<country xlink:href="http://api.spreadshirt.net/api/v1/countries/1" id="1"/>
<language xlink:href="http://api.spreadshirt.net/api/v1/languages/1" id="1"/>
<currency xlink:href="http://api.spreadshirt.net/api/v1/currencies/1" id="1"/>
...
</shop>
The currency, such as currency 1 defines the currency symbol, the price pattern and the decimal count.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<currency xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://api.spreadshirt.net"
xlink:href="http://api.spreadshirt.net/api/v1/currencies/1" id="1">
<plain>EUR</plain>
<isoCode>EUR</isoCode>
<symbol>€</symbol>
<decimalCount>2</decimalCount>
<pattern>% $</pattern>
</currency>
The country, such as country 1 defines the thousands separator and the decimal point.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<country xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://api.spreadshirt.net"
xlink:href="http://api.spreadshirt.net/api/v1/countries/1" id="1">
<isoCode>DE</isoCode>
<thousandsSeparator>.</thousandsSeparator>
<decimalPoint>,</decimalPoint>
<length>
<unit>cm</unit>
<unitFactor>1.0</unitFactor>
</length>
<currency xlink:href="http://api.spreadshirt.net/api/v1/currencies/1" id="1"/>
</country>