• Resolved masterez

    (@masterez)


    Hello,

    how to make absolute filters like “If … and…, then…”, instead of “If…or…, then…” in an attribute section?

    In my example I have an attribute section called “features” where I list computer features. It says “HDMI Output(s)(1)” and “Media Card Reader(1)”. When I click on “HDMI Output(s)(1)”, then “Media Card Reader(1)” should turn into “Media Card Reader(0)”, but it is still “Media Card Reader(1)”. So when I check also “Media Card Reader(1)”, then I see two products.

    Hope you understand what I mean. Feel free to ask questions.
    Thank you in advance.

    Best regards,
    Ismar

    https://www.ads-software.com/plugins/woocommerce-products-filter/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author RealMag777

    (@realmag777)

    Hello Ismar

    Its possible resolve with https://www.woocommerce-filter.com/hook/woof_products_query/ but for ajax mode for shop OR for [woof_products] shortcode

    As I understood you want to apply logic ‘AND’ for the same taxonomy terms which by default works by logic ‘OR’!?

    Thread Starter masterez

    (@masterez)

    Hello RealMag777,

    thank you very much for your help. You understood me right.

    I tried the function on the website you linked, but it didn’t work yet. Maybe it’s because I didn’t use the function right. This is what I put in my functions.php:

    add_filter(‘woof_products_query’, ‘my_woof_products_query’);
    function my_woof_products_query($query)
    {
    $relations = array(
    ‘product_tag’ => ‘AND’
    );
    if (!empty($query[‘tax_query’]))
    {
    foreach ($query[‘tax_query’] as $key => $value)
    {
    if (in_array($value[‘features‘], array_keys($relations)))
    {
    $query[‘tax_query’][$key][‘AND‘] = $relations[$value[‘features‘]];
    }
    }
    }
    return $query;
    }

    If I made a mistake, I will be greatfull if you can tell me.
    Thank you very much in advance.

    Best regards,
    Ismar

    Plugin Author RealMag777

    (@realmag777)

    Hello Ismar

    https://c2n.me/3xMsj4h.png – write your taxonomies slugs here for which you want to set ‘AND’ logic …

    Thread Starter masterez

    (@masterez)

    rsolved

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Absolute filters’ is closed to new replies.