How to determine selected theme style in liquid?

Hello,

I’m making some updates to Debut and I need to know which theme style has been selected from the Customize area.

How can I get this information?

I tried this:

var Shopify = Shopify || {};
Shopify.theme = Shopify.theme || {};

console.log(Shopify.theme.style)

However, what I get are null values even though I have selected a specific style:

Matt99_1-1623765882290.png

One thing I notice is that even though I have selected a style, it doesn’t seem to stay selected (have the small green border on the left side).
What could be causing this issue?

Thanks in advance!

Hi @Matt99 ,

It really doesn’t work well now, but if you want to look it up, it’s in the config/settings_data.json file. Refer https://i.imgur.com/4BGwZFd.png

Hope it helps!

Hi @LitExtension ,

Thanks for the reply.

I can see it in config/settings_data.json, but I need a way to check which style is currently selected on the theme and use this information in the liquid code.
And I can’t do this from settings_data.json directly.

Hi @Matt99 ,

You can add a json variable to check this: https://i.imgur.com/gN2VP8q.png

Then you can add the variable or check it at the layout file with code: {{ settings | json }} . Ex: https://i.imgur.com/TSAGeyD.png

Note: Shopify is developing this, it doesn’t really work well and there are many bugs. Therefore, you should be careful in using it.

Hi @LitExtension

Thanks for the reply.

Unfortunately, I already tried this yesterday and it’s not working as well.

Hope Shopify will develop a solution for this bug.