How do I use a toggle parameter in a condition?

Hi I’m new to CS and all this, so sorry if I’m totally missing something. I created my first component yesterday (A card element for WooCommerce products) and there is a part of the card that I want to add or remove based on a parameter in the component. I have searched the web, this form, and read up everything i could find on the docs but I can’t get it to work.

I have set up the parameter on the exported component element like so: (and it shows up in the Params tab)

{
  "supported-games" :{
    "type":"toggle",
    "label":"Supported Games"
  }
}

Now I want to use the value of that toggle (which I assume is true or false) as one part of a condition to show a child element of the component. I have looked all through the list of available condition choices and nothing hints at being for checking a parameter value, or dynamic content or anything like that. I did try the string option, and setting it up like {{dc:p.supported-games}} is not False but that doesn’t work, probably becase a toggle is a bool not a string.

Hello Jeffrey,

Thanks for writing in!

You will have to use {{dc:param:supported-games}} == 1

image

image

Hope this helps.

Awesome thanks so much for the help!

Could the fact that a toggle is considered a number with a value of 0 or 1 be added to the docs for those of us who are less technical: Parameters Toggle Control Docs

Also I see that its not possible to put multiple toggles into a group, as putting a toggle in a group has special formatting to make it a single option beside the group name (I’m guessing for enabling or disabling things within it). Any other toggles in the group simply disappear from the interface.

Hey Jeffrey,

Could you share your complete JSON parameter so we can check? If you are putting them in a group, you can use Groupping Controls and the Conditional Parameters.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.