Set default block in Country Selector

ClubLLondon
New Member
1 0 0

Hi Guys,

 

I have some customer content on the site to swap between our stores in different regions, UK, US and AUS.

 

On my store they each have a block which related to the flag on the site. I'm looking at setting the top one as default but I'm not having much luck, so when users select an option it takes them to the new store, but then if they come back to the main store the flag sticks as the selection they made (eg they will be back on the UK store, but the Aus flag shows as that was the last selection they made on that site which looks confusing) how could I set a default block?

Code for the section settings is here:

"storeselection-popup": {
"type": "storeselection-popup",
"blocks": {
"1580465385276": {
"type": "store_option",
"settings": {
"title": "UK",
"image": "shopify:\/\/shop_images\/united-kingdom-flag-xs.jpg",
"url": "http:\/\/www.clubllondon.com"
}
},
"1580465793584": {
"type": "store_option",
"settings": {
"title": "USA",
"image": "shopify:\/\/shop_images\/united-states-of-america-flag-xs.jpg",
"url": "https:\/\/clubllondon.us\/"
}
},
"1580734597466": {
"type": "store_option",
"settings": {
"title": "Canada",
"image": "shopify:\/\/shop_images\/canada-flag-xs.jpg",
"url": "https:\/\/clubllondon.us\/"
}
},
"1599062337029": {
"type": "store_option",
"settings": {
"title": "Australia <br>New Zealand",
"image": "shopify:\/\/shop_images\/aus-flag_320x320_9a5a19e7-2ae4-4ab1-832f-82c9681625f4.jpg",
"url": "http:\/\/www.clubllondon.com.au"
}
},
"1580739491243": {
"type": "store_option",
"settings": {
"title": "Rest of <br> the World",
"image": "shopify:\/\/shop_images\/rest-of-world.jpg",
"url": "http:\/\/www.clubllondon.com"
}
}
},
"block_order": [
"1580465385276",
"1580465793584",
"1580734597466",
"1599062337029",
"1580739491243"
],
"settings": {
"enable": true,
"drop_shadow": true,
"sidebar_bg_color": "#000000",
"sidebar_txt_color": "#ffffff",
"logo": "shopify:\/\/shop_images\/CLUBL_LOGO_LONDON_WHITE.png",
"heading_italic": "Choose your",
"heading": "Location",
"bg_img": "shopify:\/\/shop_images\/LandingPage--Store-Selector-Template.jpg",
"preferences_text": "Students get 15% off",
"preferences_image": "shopify:\/\/shop_images\/cards.jpg"
}
},

 

0 Likes
gina-gregory
Shopify Expert
710 48 176

I'm not sure how your site selector is set up in your HTML, but you could do something like this:

 

<select>
{% for block in section.blocks %}
  <option value="{{ block.settings.url }}" {% if block.settings.url contains request.host %} selected="selected"{% endif %}>{{ block.settings.title }}</option>
{% endfor %}
</select>

 

 

0 Likes