Using the Shopify Theme API (Link), I'd like to be able to get the theme ID for the currently active (main) theme.
I'm using the api gem as follows:
Shopify::Theme.find(:all, :params => { :role => 'published' })
It returns every installed theme and not just the main, published theme. Can I access a Theme this way?
You can't filter on role the way you're trying to.
However, seeing as each shop can only have a maximum of 8 themes it's not much effort to simply grab all the themes with ShopifyAPI::Theme.all and then search through them for the one being used as the main one.
You can also try getting the ID through Assets like this:
@theme_asset = ShopifyAPI::Asset.find('layout/theme.liquid')
@theme_asset.theme_id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With