HUSKY - Product Filter for WooCommerce

Filtro prodotti per Elementor: usare HUSKY con Elementor

HUSKY funziona con i negozi WooCommerce creati in Elementor. Aggiungi il filtro a qualsiasi pagina con lo shortcode [woof] in un widget Shortcode, oppure lascialo nella sidebar come widget normale.

Se la griglia dei prodotti è generata da Elementor stesso (un loop personalizzato o un template prodotti), collegala al filtro con questo codice nel functions.php del tema child:

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;
});

Decommenta is_page(__YOUR_PAGE_ID__) per attivare il filtraggio solo su una pagina specifica.

Se l'editor di Elementor non si apre più con HUSKY attivo, rimuovi la registrazione del widget HUSKY da Elementor:

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

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

});

Vedi anche: Compatibilità con Elementor, Rendi filtabili page builder e template personalizzati