How to get the current session language?

Hello is stored in somewhere the language of the current session?

Hi There,

You can change the language via the javascript API.

<script>
    document.addEventListener('snipcart.ready', function() {
        Snipcart.api.session.setLanguage('fr');
    });
</script>

You will find more information here.

Yes I know but I have some problem and I opened this issue

My question here was how to get the current language of Snipcart in JavaScript.

I know that Snipcart give me the access to some information through the store for example Snipcart.store.getState().cart.items.count, maybe there is something like that to get the language too?

To get the current session language, you can use this:

Snipcart.store.getState().session.lang;
1 Like