HUSKY - Product Filter for WooCommerce

Elementor Product Filter: Using HUSKY with Elementor

HUSKY works with WooCommerce shops built in Elementor. Add the filter to any page with the [woof] shortcode in a Shortcode widget, or keep it in the sidebar as a regular widget.

If the product grid is rendered by Elementor itself (a custom loop or products template), connect it to the filter with this code in the child theme functions.php:

add_action('pre_get_posts', function ($query) {
    if (defined('ELEMENTOR_VERSION')) {
        if (is_object($query) AND isset($query->query['post_type'])) {
            if ($query->query['post_type'] === 'product' /* AND is_page(__YOUR_PAGE_ID__)*/) {
                global $WOOF;
                if (is_object($WOOF) AND !empty(woof()->get_request_data())) {
                    woof()->woof_products_ids_prediction(true);
                    $query->query_vars['post__in'] = $_REQUEST['woof_wp_query_ids'];
                }
            }
        }
    }

    return $query;
});

Uncomment is_page(__YOUR_PAGE_ID__) to run the filtering on one specific page only.

If the Elementor editor stops opening while HUSKY is active, unregister the HUSKY widget from Elementor:

add_action('elementor/widgets/widgets_registered', function($widgets_manager)
{

    $widgets_manager->unregister_widget_type('wp-widget-woof_widget');

});

Related: Compatibility with Elementor, Make page builders and custom template filterable