Online Store 2.0 detection

dgtlmonk
Shopify Partner
18 1 4

Is there a way to detect if the Store is v 2.0?

Replies 8 (8)
jayelkaake
Shopify Partner
6 0 0

+1

Want to know if there's a way to detect if a store is using Dawn.

 

In BigCommerce they included a Header to tell us if the store was using Stencil (which was their new theme framework) which was really helpful since we used that information to direct the signup flow properly.

dgtlmonk
Shopify Partner
18 1 4

@ jayelkaake

call the API /admin/api/2021-07/themes.json, then check for the `role` property as 'main' and check if the name is "Dawn"

 

"themes": [
    {
      "id": 124128886991,
      "name": "Dawn",
      "created_at": "2021-07-08T15:11:59+08:00",
      "updated_at": "2021-09-27T09:44:34+08:00",
      "role": "main",
      "theme_store_id": 887,
      "previewable": true,
      "processing": false,
      "admin_graphql_api_id": "gid:\/\/shopify\/Theme\/124128886991"
    },
    {
      "id": 124176466127,
      "name": "Simple",
      "created_at": "2021-07-09T21:53:12+08:00",
      "updated_at": "2021-08-13T13:46:20+08:00",
      "role": "unpublished",
      "theme_store_id": 578,
      "previewable": true,
      "processing": false,
      "admin_graphql_api_id": "gid:\/\/shopify\/Theme\/124176466127"
    }]

```

 

jayelkaake
Shopify Partner
6 0 0

Good idea!

 

Although that would only work for stores that don't rename their theme to something else...so probably 90% of the time, so still helpful!

 

Would be great to have a method that is accurate 100% of the time.

PaulNewton
Shopify Partner
4211 303 902

@dgtlmonk , @jayelkaake 

Is there a way to detect if the Store is v 2.0?


To clarify all stores are now OS2.0 stores.

To tell if a OS2.0 store has a published THEME using OS2.0 features:

get the main(published) theme and in that check in the templates folder for a JSON template for a resource that is relevant to your use case. I.e. if you need to insert something on product pages = product.json

 

💣 If you use the presence of "Dawn" in the theme name as an evaluation for expecting OS2 compatibility you are building in a bug based on false negatives AND false positives.

psuedocode 

//PSUEDOCODE
function detectOS2(theme) {
  isDawnSoMustBeOS2 = false
  if main.theme.name ~= "dawn"
    isDawnSoMustBeOS2 = true

  if isDawnSoMustBeOS2 
   return true
}


theme.name = "Debut - dawn dish shop promotion"
  detectOS2(theme)
  // > true
theme.name = "someothername"
  detectOS2(theme)
  // > false negative

 

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
PaulNewton
Shopify Partner
4211 303 902

@jayelkaake In BigCommerce they included a Header to tell us if the store was using Stencil (which was their new theme framework) which was really helpful since we used that information to direct the signup flow properly.

Be aware Dawn is NOT a framework it's just an open source REFERENCE theme a very important difference do not confuse the two.

And JSON templates are part of the OS.2 theme architecture.

 

Apps needing to modify themes just have to build their own heuristics to set conditional flags for the app behavior.

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
PaulNewton
Shopify Partner
4211 303 902

@jayelkaake wrote:

Would be great to have a method that is accurate 100% of the time.


 XYProblem , If the intent is to add features to OS2 themes in a standard manner this is through app blocks of theme app extensions.

https://shopify.dev/apps/online-store/theme-app-extensions 

https://shopify.dev/apps/online-store/theme-app-extensions/extensions-framework#app-blocks 

 

Shopify has sample code for Node to see if a theme has support for app blocks and an example app

https://shopify.dev/apps/online-store/verify-support 

https://github.com/Shopify/product-reviews-sample-app 

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
chenster
Shopify Partner
132 5 21

Is there a way to detect if the Store is v 2.0?


To clarify all stores are now OS2.0 stores.

What did you mean by "all stores are now OS2.0"? Were they all automatically migrated by Shopify to 2.0? The online helps say it's voluntary.

 

Cartoo
PaulNewton
Shopify Partner
4211 303 902

@chenster wrote:

The online helps say it's voluntary.


Use and read the full url for context of what your reading and where in the docs it is:

help.shopify.com/en/manual/online-store/THEMES/versions/upgrading 

That doc is specifically about choosing to use an old theme or upgrading themes to be useable with OS2 features which all stores have.

So yes it's "voluntary" if merchants do not want to take advantage of their stores full OS2.0 capabilities.

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com