Script To Update Theme Style On Load

LMiller
Shopify Partner
15 0 3

Morning,

 

I am building a multi-vendor store with a header that takes customers to different "shops" even though it's all the same domain. Currently my header has navigation links to subdomains for each brand (i.e. vip.transpacbrands, totaleegift.transpacbrands, etc.). And then I change the section that loads for the announcement bar and header based on the subdomain via the following code in my theme.liquid file:

 

{% case request.host %}
  {% when 'viphomeandgarden.transpacbrands.com' %}
    {% section 'announcement-bar' %}
    {% style %}
      #section-id-announcement-bar {
              --announcement-background: #66817E;
    {% endstyle %}  
  {% when 'seasonsdesigns.transpacbrands.com' %}
    {% section 'announcement-bar' %}
    {% style %}
      #section-id-announcement-bar {
              --announcement-background: #96B797;
    {% endstyle %}  
  {% when 'totaleegift.transpacbrands.com' %}
    {% section 'announcement-bar' %}
    {% style %}
      #section-id-announcement-bar {
              --announcement-background: #FF6F73;
    {% endstyle %}   
  {% else %}
    {% section 'announcement-bar' %}
  {% endcase %}
  {% case request.host %}
  {% when 'viphomeandgarden.transpacbrands.com' %}
    {% section 'header-viphomeandgarden' %}
  {% when 'totaleegift.transpacbrands.com' %}
    {% section 'header-totaleegift' %}
  {% when 'seasonsdesigns.transpacbrands.com' %}
    {% section 'header-seasonsdesigns' %}
  {% else %}
    {% section 'header' %}
  {% endcase %}

 

Now I'm trying to also change the theme style based on subdomain and need a little help. I already managed to edit the settings_data.json file so that each of the preset theme styles are correct:

LMiller_0-1707833128378.png

Upon inspecting the existing code I've found two areas where this might be used but nothing I have tried has worked...

LMiller_0-1707833546927.png

LMiller_2-1707833323011.png

From navigating my site that Shopify.theme.style is always equal to null.

 

Any help here would be greatly appreciated so I don't have to hard code in style updates to every aspect of the stylesheet 4 times. 

 

Thanks!

Reply 1 (1)

LMiller
Shopify Partner
15 0 3

Any ideas anyone?