Support Forums

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Show only items with value=””

Viewing 10 posts - 1 through 10 (of 12 total)
  • Alyson Osborn
    #238847

    I am using Woocommerce Booking. There is a checkmark option built-in that gives the value of 1 if checked and empty if unchecked. Basically, this option decides if the base price is multiplied by the number of guests (checked) or the base price is the flat rate (unchecked). Currently, if I try to use an empty value in Search and Filter Pro, it gives me “All Items”. Is there a way to filter only the items that have no value?

    Trevor Moderator
    #238892

    I suspect not, or at least not this way. In WordPress, when a field has no value, the field itself does not actually exist in the database, so there is nothing to search for. WordPress does this to cut down on storage space used. Thus, fields cannot have a NULL or ’empty’ value.

    How are you trying to use this? Assuming you want to do this in the admin only (and not as a user option in the form), you could add a Post Meta condition to test ‘not exists’.

    Alyson Osborn
    #238962

    Thank you for your response. Woocommerce booking is creating a database table for a NULL value.

    This will be used on the front end. Our customers will be selecting if they want an event that is priced per person (value=”1″) or flat rate (value=””).

    When I test the Post Meta condition “not exists” no products show up but then when I create a condition that says “not equal” to 1, the appropriate products show up. So I would like the filter to do this. How can I sort that out?

    Trevor Moderator
    #238964

    Try setting it to CHAR, NOT LIKE, 1

    OR, somehow you need to make the alternate value not black but 0, or would that too cause a problem?

    Alyson Osborn
    #238976

    Yes, if I set the CHAR, NOT LIKE, 1, I only get the “flat rate” options and not the “per person” value of 1.

    Changing the value to 0 would cause an issue, unfortunately.

    Trevor Moderator
    #238980
    This reply has been marked as private.
    Alyson Osborn
    #238985
    This reply has been marked as private.
    Trevor Moderator
    #238989
    This reply has been marked as private.
    Alyson Osborn
    #238995
    This reply has been marked as private.
    Trevor Moderator
    #239034

    I have taken a long look. Essentially, you need an option to add to the field in the form, but there are no values. I can see that the fields are there in the database, but with no value set.

    There is no way some sort of value can be set? Even one that is not a number, but maybe a word or phrase, like flatrate. I assume somewhere a calculation is being done elsewhere in the system?

    Would setting a word in the value cause that to fail? Do you have access to that code so that the calculation is done only if the word is not there?

    If not, the only other way I can see is to have a second field, based on the existing one (and hidden from the user – depending how you are making the custom fields, for example, ACF has a Hide From Admin option) that autopopulates based on the existing field, but this time has 0 or 1 in it. The code would be fairly easy to do, and can be triggered from the post save button.

Viewing 10 posts - 1 through 10 (of 12 total)

The topic ‘Show only items with value=””’ is closed to new replies.