HUSKY - Product Filter for WooCommerce

woof_draw_products_get_args

Filters the merged GET parameters passed to the woof_draw_products AJAX handler. The hook merges the URL query string from the requested link with the current parameters, giving you an opportunity to modify or extend the query data before products are rendered via the [woof_products] shortcode.

Called in two locations: the main woof_draw_products AJAX handler and the by_text extension's text search handler.

Parameters

$query_args (array) — Merged array of URL query parameters and current values, sanitized with wc_clean().

$link (string) — The raw URL from the AJAX request.

Source File

index.php, line 2728
ext/by_text/index.php, line 981

Code Example


add_filter("woof_draw_products_get_args", function ($query_args, $link) {
    // Force a specific product category in the query
    $query_args["product_cat"] = "clothing";
    return $query_args;
}, 10, 2);

Usage Notes

  • Add this code to your theme's functions.php file or a custom plugin.
  • The returned array is passed through array_map with a regex replacement for spaces after the filter runs.
  • This hook is consumed internally by the url_request and by_text extensions.
  • Accepts 2 parameters — remember to declare $a, $b in your function signature.