# How to access config field from theme.json?

**URL:** <https://forum.shopware.com/t/how-to-access-config-field-from-theme-json/101332>\
**Category:** Themes & Design (EN)\
**Created:** [21. September 2023 um 14:00 UTC](https://forum.shopware.com/t/how-to-access-config-field-from-theme-json/101332 "2023-09-21T14:00:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![magnus](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/magnus/32/13222_2.png) [@magnus](https://forum.shopware.com/u/magnus)\
**Post date:** [21. September 2023 um 14:00 UTC](https://forum.shopware.com/t/how-to-access-config-field-from-theme-json/101332/1 "2023-09-21T14:00:44Z")

</div>

I have created an new config field in theme.json. It’s a boolean field called „productsku“ with default value of „false“.

Is it possible to check this value (false or true) within a twig template? I want to use that in a if-statement to show/hide a twig block.

Have tried just to print it with „config.fields.productsku“ and „theme\_config.productsku“. But none seems to work. 🤔

Maybe not possible…?

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [21. September 2023 um 23:16 UTC](https://forum.shopware.com/t/how-to-access-config-field-from-theme-json/101332/2 "2023-09-21T23:16:15Z")

</div>

theme\_config(„var“)

Change the „ to the Cort ones, can’t type it on my device.

---

<div class="post-metadata">

**Author:** ![magnus](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/magnus/32/13222_2.png) [@magnus](https://forum.shopware.com/u/magnus)\
**Post date:** [24. September 2023 um 13:36 UTC](https://forum.shopware.com/t/how-to-access-config-field-from-theme-json/101332/3 "2023-09-24T13:36:24Z")

</div>

Thanks Max - and sorry for a late reply.

I tried this (inside a block of an extended template), but nothing is printed.  
`theme_config("productsku")`

The config field have a default value of „false“.

I must be missing something other, important. 😆

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [24. September 2023 um 21:32 UTC](https://forum.shopware.com/t/how-to-access-config-field-from-theme-json/101332/4 "2023-09-24T21:32:20Z")

</div>

With that function you only get the value. If you want to print it use {{ … }} around the function. Honestly I don’t know what will happen if you print a bool value. Maybe false converts to null and then you won’t see anything.

---

<div class="post-metadata">

**Author:** ![magnus](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/magnus/32/13222_2.png) [@magnus](https://forum.shopware.com/u/magnus)\
**Post date:** [25. September 2023 um 04:33 UTC](https://forum.shopware.com/t/how-to-access-config-field-from-theme-json/101332/5 "2023-09-25T04:33:11Z")

</div>

Yes, I’m already using the {{ … }}  
Maybe it is so that a false boolean dont print anything…

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [25. September 2023 um 07:22 UTC](https://forum.shopware.com/t/how-to-access-config-field-from-theme-json/101332/6 "2023-09-25T07:22:06Z")

</div>

Try it with {{ false }} and {{ true }} in your template and then you know for sure.

Use the twig manual, maybe you can cast Boolean to string or write your own twig function.

---

<div class="post-metadata">

**Author:** ![magnus](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/magnus/32/13222_2.png) [@magnus](https://forum.shopware.com/u/magnus)\
**Post date:** [25. September 2023 um 14:35 UTC](https://forum.shopware.com/t/how-to-access-config-field-from-theme-json/101332/7 "2023-09-25T14:35:38Z")

</div>

Great!  
I went straight in tried with an if-statement - and it works perfect 😃

```auto
{% if theme_config("productsku") %}
 // some code to show the product SKU
{% endif %}

```
