PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]
Botoscope is currently in early access

Support Forum

You need to log-in to create request (topic) to the support

ACF field

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi there.
I am testing your plugin which seems great.
However I have a problem with ACF field.
I created one, which is a list of terms, but in the filter I can't set it as Multi Drop-Down list.
I want user to be able to chose several terms.
Is that possible?

Thank you in advance.

Hello

Out of the box the plugin does not support pulling ACF field values automatically into the Multi Drop-Down filter, but it is achievable via hooks.

But we can suggest an idea:

Step 1 — Populate the dropdown options dynamically from ACF data

Add this snippet to your theme's functions.php or a snippet plugin:

add_filter('woof_modify_settings_before_action', function($settings, $atts) {
    global $wpdb;
    $acf_key = 'your_acf_field_name'; // replace with your actual ACF field name

    $values = $wpdb->get_col($wpdb->prepare(
       "SELECT DISTINCT meta_value FROM {$wpdb->postmeta}
         WHERE meta_key = %s AND meta_value != ''
         ORDER BY meta_value ASC",
        $acf_key
    ));

    if (!empty($values)) {
        $settings['meta_filter'][$acf_key]['options'] = implode(',', $values);
    }

    return $settings;
}, 10, 2);

This will dynamically pull all unique values from your products and populate the dropdown automatically.


Important nuance — how the search works internally

The plugin builds the meta query inside:
ext/meta_filter/html_types/mselect/index.php → create_meta_query()

The relevant part:

$meta[] = array(
    'key'     => $this->meta_key,
    'value'   => $curr_text,
    'compare' => '=',   // plain string equality
    'type'    => $this->value_type,
);

This works correctly only if your ACF field is a single select — in that case ACF stores the value as a plain string in wp_postmeta, so compare='=' matches it fine.

However, if your ACF field is a multiselect, ACF serializes the data in the database like this:

a:2:{i:0;s:6:"value1";i:1;s:6:"value2";}

In that case compare='=' will never match and the filter will return no results.


Step 2 — Fix the search for ACF multiselect (if needed)

You can fix this without editing the plugin file by intercepting the meta query via hook:

add_filter('woof_get_meta_query', function($meta_query) {
    $acf_key = 'your_acf_field_name'; // replace with your actual ACF field name

    foreach ($meta_query as &$group) {
        if (is_array($group)) {
            foreach ($group as &$clause) {
                if (is_array($clause) && isset($clause['key']) && $clause['key'] === $acf_key) {
                    // ACF multiselect stores serialized arrays, LIKE is required
                    $clause['value']   = '"' . $clause['value'] . '"';
                    $clause['compare'] = 'LIKE';
                }
            }
        }
    }

    return $meta_query;
});

This switches the comparison from = to LIKE with the correct ACF serialization format, so it will properly match multiselect values stored in the database.

Please test both snippets with your setup and let us know how it goes!

Thank you Alex for your help.
I tried to add the first snippet, but I could not see any difference in Husky / Structure.

 

Hello

Undertood, I created task to review this as suggested feature, if that will be possible its will be implemented in next versions of the plugin, but for now unfortunately it doesn work from the box ...

 

thank you @alexdev for your help !

Welcome :)