Re: How to check if environment in Shopify is Dev or Production?

How to check if environment in Shopify is Dev or Production?

phillip12
Shopify Partner
16 2 9

Hi, I want to check if I'm inside the dev or prod environment within Liquid. 

  • I have a live store and set up a development store
  • I'm developing locally with Shopify CLI

1. attempt

I found a .env file, but I don't know how to read the variables that are inside the .env within Liquid.

 

2. attempt

I added new settings to the settings_data.json but I don't know where these settings should appear. I don't find them inside my admin backend

 

This is my JSON

```json

"settings": [
{
"label": "Environment",
"id": "environment",
"type": "select",
"options": [
{
"label": "Development",
"value": "development"
},
{
"label": "Production",
"value": "production"
}
],
"default": "production"
},
{
"label": "Klaviyo Account",
"id": "klaviyo_account",
"type": "text",
"default": "XXXXXX"
}
],
```
 
Can anyone help?

 

Replies 5 (5)

Columbus_Themes
Shopify Partner
121 9 16

I hope i understood your issue, you need to know either your are in the Theme Editor or in the actual website it self?

Use the Shopify.designMode in JS and request.design_mode in Liquid.

Check this link from Shopify's team:

https://shopify.dev/changelog/detect-the-theme-editor-using-liquid-and-javascript

Hope it helped.

If you find my reply helpful, please hit Like and Mark as Solution.

Happy coding!
shipify
Shopify Partner
7 0 0

DEVELOPMENT = SANDBOX, PRODUCTION = LIVE

 

If `DesignMode` = true, your shop is being EDITED, totally different thing from sandbox and live

 

 

shipify
Shopify Partner
7 0 0

did you managed to find a solution?

vinayakakv
Shopify Partner
2 1 1

I saw usages of `theme.role` Liquid variable to determine if the theme is in developement or prod.

 

Not sure if that corresponds to the store being in dev or prod.

 

shipify
Shopify Partner
7 0 0

Hmm interesting, it could be repurposed as dev vs prod