ndiego / block-visibility

Conditional visibility controls for all WordPress blocks.
https://www.blockvisibilitywp.com
GNU General Public License v2.0
123 stars 10 forks source link

cookie_value_compare function 'contains' does not work #110

Closed SerhiiMazurBeetroot closed 1 month ago

SerhiiMazurBeetroot commented 1 month ago

Description

This is my first experience with your plugin. And I realized that the "value contains" cookie visibility rule is not working properly.

Step-by-step reproduction instructions

  1. Add controls 'Cookie'
  2. Fill in the cookie_name: 'cookie_name'
  3. Select 'value contains'
  4. Enter: 'value1, value2' or 'value1 value2'
  5. It doesn't work

Expected behavior

This should work

Actual behavior

It doesn't work

Screenshots or screen recording (optional)

Vc496C8

System information

ndiego commented 1 month ago

Thanks for logging this issue. However, it seems to be working properly for me. This is my testing setup.

Cookie Visibility settings
image image

Note that the value field does not support multiple options. Currently, if you want to check for multiple values and create an OR condition, you need to add an additional Rule Set, like this:

image
SerhiiMazurBeetroot commented 1 month ago

In case you enter 1 value - I agree, it's working. As I expected, this one will take multiple values. Did you plan to add an option to enter multiple values ​​to compare to the cookie (in case it has single value)?

Thanks in advance!

ndiego commented 1 month ago

Did you plan to add an option to enter multiple values ​​to compare to the cookie (in case it has single value)?

Perhaps in the future, but this is the first time it's been requested. Using multiple Rule Sets, as outlined in the comment above, does provide a solution when you need to evaluate multiple values using an OR condition. If you need to compare multiple values using an AND condition, you can add an additional rule to the same Rule Set. See below for both setups.

OR condition AND condition
image image

So, while I agree that being able to add multiple values to the field would be easier, you can still accomplish what you are looking for using the existing setup.