SyliusCon 2025 in Lyon
Join Us!
LogoLogo
🛣️ Roadmap💻 Sylius Demo💬 Community Slack
  • Sylius Documentation
  • Sylius Plugins
  • Sylius Stack
  • 📖Sylius Documentation
  • Organization
    • Sylius Team
  • Release Cycle
    • Backwards Compatibility Promise
  • Getting Started with Sylius
    • Installation
    • Basic Configuration
    • Shipping & Payment
    • First Product
    • Customizing the Shop
    • Customizing Business Logic
    • Using API
    • Installing Plugins
    • Deployment
    • Summary
  • The Book
    • Introduction to Sylius
    • Installation
      • System Requirements
      • Sylius CE Installation
        • Sylius CE Installation with Docker
      • ➕Sylius Plus Installation
      • Upgrading Sylius CE
      • Upgrading Sylius Plus
    • Architecture
      • Architecture Overview
      • Architectural Drivers
      • Resource Layer
      • State Machine
      • Translations
      • E-Mails
      • Contact
      • Fixtures
      • Events
    • Configuration
      • Channels
      • Locales
      • Currencies
    • Customers
      • Customer & ShopUser
      • ➕Customer Pools
      • AdminUser
      • Addresses
        • Countries
        • Zones
        • Addresses
        • Address Book
    • Products
      • Products
      • Product Reviews
      • Product Associations
      • Attributes
      • Pricing
      • Catalog Promotions
      • Taxons
      • Inventory
      • ➕Multi-Source Inventory
      • Search
    • Carts & Orders
      • Orders
      • Cart flow
      • Taxation
      • Adjustments
      • Cart Promotions
      • Coupons
      • Payments
      • 🧩Invoices
      • Shipments
    • 🎨Frontend & Themes
    • Support
    • Contributing
      • Contributing Code
        • Submitting a Patch
        • ⚠️Security Issues
        • Coding Standards
        • Conventions
        • Sylius License and Trademark
      • Contributing Translations
      • Key Contributors
  • The Customization Guide
    • Customizing Models
      • How to add a custom model?
      • How to add a custom translatable model?
    • Customizing Forms
      • How to add a live form for a custom model?
    • Customizing Templates
    • Customizing Styles
    • Customizing Dynamic Elements
    • Customizing Validation
    • Customizing Menus
    • Customizing Translations
    • Customizing Flashes
    • Customizing State Machines
    • Customizing Grids
    • Customizing Fixtures
    • Customizing API
    • Customizing Serialization of API
    • Customizing Payments
      • How to integrate a Payment Gateway as a Plugin?
  • 🧑‍🍳The Cookbook
  • How to resize images?
  • How to add one image to an entity?
  • How to add multiple images to an entity?
  • How to add a custom cart promotion action?
  • How to add a custom cart promotion rule?
  • Sylius 1.X Documentation
    • 📓Sylius 1.x Documentation
Powered by GitBook
LogoLogo

Developer

  • Community
  • Online Course

About

  • Team

© 2025 Sylius. All Rights Reserved

On this page
  • Currency Context
  • Getting the list of available currencies for a channel
  • Currency Converter
  • Switching Currency of a Channel
  • Displaying Currencies in the templates

Was this helpful?

Edit on GitHub
  1. The Book
  2. Configuration

Currencies

Sylius supports multiple currencies per store and makes it very easy to manage them.

There are several approaches to processing several currencies, but we decided to use the simplest solution: storing all money values in the base currency per channel and converting them to other currencies with exchange rates.

The base currency to the first channel is set during the installation of Sylius and it has an exchange rate equal to “1.000”.

In the dev environment, you can easily check the base currency in the Symfony debug toolbar.

Currency Context

By default, the user can switch the current currency in the frontend of the store.

To manage the currently used currency, we use the CurrencyContext. You can always access it through the sylius.context.currency id.

public function fooAction()
{
    $currency = $this->get('sylius.context.currency')->getCurrency();
}

Getting the list of available currencies for a channel

If you want to get a list of currently available currencies for a given channel, you can get them from the Channel. You can also get the current Channel from the container.

public function fooAction()
{
    // If you don't have it, you can get the current channel from the container
    $channel = $this->container->get('sylius.context.channel')->getChannel();

    $currencies = $channel->getCurrencies();
}

Currency Converter

The Sylius\Component\Currency\Converter\CurrencyConverter is a service available under the sylius.currency_converter id.

It allows you to convert money values from one currency to another.

This solution is used for displaying an approximate value of price when the desired currency is different from the base currency of the current channel.

Switching Currency of a Channel

We may of course change the currency used by a channel. For that we have the sylius.storage.currency service, which implements the Sylius\Component\Core\Currency\CurrencyStorageInterface with methods ->set(ChannelInterface $channel, $currencyCode) and ->get(ChannelInterface $channel).

$container->get('sylius.storage.currency')->set($channel, 'PLN');

Displaying Currencies in the templates

There are some useful helpers for rendering money values in the front end. Simply import the money macros of the ShopBundle in your twig template and use the functions to display the value:

..
{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
..

<span class="price">{{ money.format(price, 'EUR') }}</span>

Sylius provides you with some handy Global Twig variables to facilitate displaying money values even more.

PreviousLocalesNextCustomers

Last updated 8 months ago

Was this helpful?

If you want to learn more about Channels, what they represent, and how they work; read the previous chapter

Channels