Woocommerce Products Filter Shortcodes

Below, you’ll find a detailed guide on how to add the Woocommerce Products Filter Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Woocommerce Products Filter Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Woocommerce Products Filter Plugin and the shortcodes it provides:

Plugin Icon
HUSKY – Products Filter for WooCommerce Professional

"HUSKY – Products Filter for WooCommerce Professional is a powerful plugin that enhances your WooCommerce store by providing advanced filtering options. It streamlines product searches for a better user experience."

★★★★☆ (287) Active Installs: 100000+ Tested with: 6.3.2 PHP Version: 7.3
Included Shortcodes:
  • [woof_author_filter]
  • [woof_text_filter]
  • [woof_front_builder]
  • [woof_products_messenger]
  • [woof_save_query]
  • [woof_quick_search]
  • [woof_quick_search_results]
  • [woof_slideout]
  • [woof_step]
  • [woof]
  • [woof_btn]
  • [woof_mobile]
  • [woof_products]
  • [woof_products_ids_prediction]
  • [woof_price_filter]
  • [woof_search_options]
  • [woof_found_count]
  • [woof_ajax_shortcode]

Woocommerce Products Filter [woof_author_filter] Shortcode

The Woocommerce Products Filter shortcode is designed to filter products by author. It checks for an override file in a specific directory. If it exists, it renders the HTML from that file. If not, it uses the default file.

Shortcode: [woof_author_filter]

Examples and Usage

Basic example – A simple implementation of the woof_author_filter shortcode. This usage doesn’t include any attributes and will utilize the default settings defined within the plugin.

[woof_author_filter]

Advanced examples

Implementing the woof_author_filter shortcode with a custom attribute. In this example, we are passing a custom argument to the shortcode. The ‘author’ attribute allows you to filter products by a specific author.

[woof_author_filter author="John Doe"]

Using multiple attributes within the woof_author_filter shortcode. This example demonstrates how to pass multiple attributes to the shortcode. The ‘author’ attribute filters products by author, while the ‘category’ attribute filters products within a specific category.

[woof_author_filter author="John Doe" category="Books"]

It’s important to note that the values assigned to the shortcode attributes must match exactly with the author name or category name in your WooCommerce store for the filter to work correctly.

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_author_filter] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_author_filter', array($this, 'woof_author_filter'));

Shortcode PHP function:

function woof_author_filter($args = array()) {
        
        if (file_exists($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_author_filter.php')) {
            return woof()->render_html($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_author_filter.php', $args);
        }
        return woof()->render_html($this->get_ext_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_author_filter.php', $args);
    }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/ext/by_author/index.php

Woocommerce Products Filter [woof_text_filter] Shortcode

The Woocommerce Products Filter shortcode is a tool that allows users to apply text filters to their product searches. This shortcode checks if an array of arguments exists. If not, it creates one. It then sets a loading image and checks if a custom override path exists. If it does, it renders the HTML from the override path. If it doesn’t, it renders the HTML from the default path.

Shortcode: [woof_text_filter]

Examples and Usage

Basic example – A simple usage of the woof_text_filter shortcode without any additional parameters.

[woof_text_filter]

Advanced examples

Using the woof_text_filter shortcode with a loader image. This will display a loading gif while the filter is being processed.

[woof_text_filter loader_img="path_to_your_loader_image.gif"]

Applying the woof_text_filter shortcode with a specific view. This will use a custom view file for the filter, which you need to place in the correct directory.

[woof_text_filter view="path_to_your_custom_view.php"]

Combining both loader image and custom view in the woof_text_filter shortcode. This example shows how you can use multiple parameters with the shortcode.

[woof_text_filter loader_img="path_to_your_loader_image.gif" view="path_to_your_custom_view.php"]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_text_filter] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_text_filter', array($this, 'woof_text_filter'));

Shortcode PHP function:

function woof_text_filter($args = array()) {

        if (!is_array($args)) {
            $args = array();
        }

        $args['loader_img'] = $this->get_ext_link() . 'img/loader.gif';

        if (file_exists($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_text_filter.php')) {
            return woof()->render_html($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_text_filter.php', ['data' => $this->data_fields($args)]);
        }

        return woof()->render_html($this->get_ext_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_text_filter.php', ['data' => $this->data_fields($args)]);
    }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/ext/by_text/index.php

Woocommerce Products Filter [woof_front_builder] Shortcode

The Woocommerce Products Filter shortcode, “woof_front_builder”, is designed to manage the front-end display of product filters. It allows customization of filter attributes such as popup width and height. The shortcode also adjusts settings based on the user’s admin status and provides options for layout and section layout. It supports both redirect and ajax mode for filter sections.

Shortcode: [woof_front_builder]

Parameters

Here is a list of all possible woof_front_builder shortcode parameters and attributes:

  • name – Provides a unique name for the shortcode [woof_front_builder]
  • popup_width – Defines the width of the popup window in pixels
  • popup_height – Specifies the height of the popup window in pixels

Examples and Usage

Basic example – A simple usage of the woof_front_builder shortcode to create a WooCommerce product filter with a unique name.

[woof_front_builder name="my_filter" /]

Advanced examples

Utilizing the woof_front_builder shortcode to create a WooCommerce product filter with a unique name, and defining the popup window’s width and height.

[woof_front_builder name="my_advanced_filter" popup_width="900" popup_height="700" /]

Creating a WooCommerce product filter with a unique name and setting the popup window’s width. The height will default to ‘600px’ if not specified.

[woof_front_builder name="my_custom_width_filter" popup_width="1000" /]

Using the woof_front_builder shortcode to create a WooCommerce product filter with a unique name while only defining the popup window’s height. The width will default to ‘800px’ if not specified.

[woof_front_builder name="my_custom_height_filter" popup_height="800" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_front_builder] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("woof_front_builder", array($this, "woof_front_builder"));

Shortcode PHP function:

function woof_front_builder($atts, $content = '') {

        if (!isset($atts['name'])) {
            return esc_html__('Unique name should be set for shortcode [woof_front_builder]', 'woocommerce-products-filter');
        }

        $name = esc_html($atts['name']);
        if ($this->demo) {
            $name .= ' ' . str_replace(':', '', str_replace('.', '', filter_var(WOOF_HELPER::get_server_var('REMOTE_ADDR'), FILTER_VALIDATE_IP)));
        }

        $is_admin = $this->is_admin();

        if ($is_admin) {
            $answer = $this->install();
            if ($answer) {
                return $answer;
            }
        }

        $data = $this->get_data($name);
        $data['is_admin'] = $is_admin;

        //+++

        if (isset($atts['popup_width'])) {
            $data['popup_width'] = intval($atts['popup_width']) . 'px';
        } else {
            $data['popup_width'] = isset($this->additional->get($name)['popup_width']) ? $this->additional->get($name)['popup_width'] . 'px' : '800px';
        }

        if (isset($atts['popup_height'])) {
            $data['popup_height'] = intval($atts['popup_height']) . 'px';
        } else {
            $data['popup_height'] = isset($this->additional->get($name)['popup_height']) ? $this->additional->get($name)['popup_height'] . 'px' : '600px';
        }

        //+++

        $data['options'] = $this->options->get_options_key_value($name);
        $data['layout_options'] = $this->options_layout->get_options_key_value($name);
        $data['sections_layout_options'] = $this->options_sections_layout->get_options_db($name);

        $data['ext_link'] = $this->get_ext_link();
        $viewtypes = array_merge(woof()->settings['tax_type'], $this->viewtypes->get($name));
        $data['viewtypes'] = '';
        if (!empty($viewtypes)) {
            foreach ($viewtypes as $key => $value) {
                $data['viewtypes'] .= $key . ':' . $value . ',';
            }
            $data['viewtypes'] = trim($data['viewtypes'], ',');
        }

        //fix for redirect + ajax mode filter-sections order
        $data['options']['items_order'] = $this->get_selected_by_name($name);

        if ($this->demo) {
            $data['options']['dynamic_recount'] = 0;
            $data['options']['hide_terms_count'] = 1;
        }

        return woof()->render_html($this->get_ext_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_front_builder.php', $data);
    }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/ext/front_builder/index.php

Woocommerce Products Filter [woof_products_messenger] Shortcode

The Woocommerce Products Filter (WOOF) shortcode is designed to display a messenger for products. It uses the ‘woof_products_messenger_shortcode’ function to render HTML from a specific path. If the file exists in the override path, it’s used. Otherwise, the file from the extension path is used. This allows for customization of the messenger’s appearance.

Shortcode: [woof_products_messenger]

Parameters

Here is a list of all possible woof_products_messenger shortcode parameters and attributes:

  • in_filter – Decides if the messenger is within the filter or not

Examples and Usage

Basic Example – The given shortcode is used to display the Woocommerce Products Filter Messenger. By default, the ‘in_filter’ parameter is set to 0. This means the messenger is not included in the filter.

[woof_products_messenger in_filter=0 /]

Advanced Examples

1. Displaying the Woocommerce Products Filter Messenger within the filter. To do this, you would set the ‘in_filter’ parameter to 1. This means the messenger is included in the filter and will be displayed accordingly.

[woof_products_messenger in_filter=1 /]

2. Providing a custom ‘ext_link’ parameter. This parameter allows you to specify a custom external link to be used in the messenger. Replace ‘your-link-here’ with the actual link you want to use.

[woof_products_messenger in_filter=1 ext_link='your-link-here' /]

Please note that ‘ext_link’ is not a predefined parameter in the shortcode function. You would need to modify the ‘woof_products_messenger_shortcode’ function to accept and use this parameter.

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_products_messenger] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_products_messenger', array($this, 'woof_products_messenger_shortcode'));

Shortcode PHP function:

function woof_products_messenger_shortcode($args) {
        $data = shortcode_atts(array(
            'in_filter' => 0
                ), $args);

        $data['ext_link'] = $this->get_ext_link();

        if (file_exists($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_products_messenger.php')) {
            return woof()->render_html($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_products_messenger.php', $data);
        }
        return woof()->render_html($this->get_ext_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_products_messenger.php', $data);
    }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/ext/products_messenger/index.php

Woocommerce Products Filter [woof_save_query] Shortcode

The Woocommerce Products Filter (WOOF) shortcode, ‘woof_save_query’, is designed to save and render a specific product query. It uses the ‘in_filter’ argument to determine if the query is within the filter. If an override path exists, it renders the HTML from there. If not, it retrieves the extension link and renders the HTML from the default path.

Shortcode: [woof_save_query]

Parameters

Here is a list of all possible woof_save_query shortcode parameters and attributes:

  • in_filter – Determines if the saved query is used within the filter

Examples and Usage

Basic example – Display a saved WooCommerce filter query without any additional parameters.

[woof_save_query /]

Advanced examples

Display a saved WooCommerce filter query and specify whether it should be included in the filter or not using the ‘in_filter’ parameter. The value of ‘1’ indicates that the saved query should be included in the filter.

[woof_save_query in_filter=1 /]

Display a saved WooCommerce filter query and specify whether it should be included in the filter or not using the ‘in_filter’ parameter. The value of ‘0’ indicates that the saved query should not be included in the filter.

[woof_save_query in_filter=0 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_save_query] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_save_query', array($this, 'woof_save_query'));

Shortcode PHP function:

function woof_save_query($args) {
        $data = shortcode_atts(array(
            'in_filter' => 0
                ), $args);

        if (file_exists($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_save_query.php')) {
            return woof()->render_html($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_save_query.php', $data);
        }
        
        $data['ext_link']= $this->get_ext_link();
        return woof()->render_html($this->get_ext_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_save_query.php', $data);
    }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/ext/query_save/index.php

Woocommerce Products Filter [woof_quick_search] Shortcode

The Woocommerce-products-filter plugin shortcode, ‘woof_quick_search’, allows you to customize the quick search feature on your website. This shortcode supports various attributes like ‘preload’, ‘placeholder’, ‘price_filter’, ‘extended_filter’, ‘target’, ‘reset_btn’, ‘add_filters’, ‘filter_title’, ‘term_logic’, ‘tax_logic’, and ‘text_group_logic’. Each attribute serves a unique function to enhance the search functionality.

Shortcode: [woof_quick_search]

Parameters

Here is a list of all possible woof_quick_search shortcode parameters and attributes:

  • short_id – Unique identifier when using multiple data files.
  • preload – Controls file download: 1 for page load, 0 for click.
  • placeholder – Text displayed in the search field.
  • price_filter – Enables price filter: 1 to show, 0 to hide.
  • extended_filter – Activates extended filter: 1 for use, 0 to disable.
  • target – Defines link behavior, ‘_blank’ opens in a new tab.
  • reset_btn – Controls reset button: 1 to display, 0 to hide.
  • add_filters – Specifies filter types and related taxonomies.
  • filter_title – Sets custom titles for filters.
  • term_logic – Sets logic between terms in a taxonomy.
  • tax_logic – Defines logic between taxonomies: ‘AND’ or ‘OR’.
  • text_group_logic – Sets search logic for multiple words: ‘AND’ or ‘OR’.

Examples and Usage

Basic example – A simple usage of the ‘woof_quick_search’ shortcode to create a quick search feature with a placeholder text for the search field.

[woof_quick_search placeholder="Search products..."]

Advanced examples

Using the ‘woof_quick_search’ shortcode to create a quick search feature with a placeholder text, a price filter, and a reset button.

[woof_quick_search placeholder="Search products..." price_filter=1 reset_btn=1]

Using the ‘woof_quick_search’ shortcode to create a quick search feature with extended filter functionality, additional filter types, filter titles, and logic for terms and taxonomies.

[woof_quick_search extended_filter=1 add_filters="drop-down:product_cat,multi-drop-down:pa_size" filter_title="product_cat:Type,pa_size:Color of the item" term_logic="pa_color:AND,product_cat:OR" tax_logic="AND"]

Using the ‘woof_quick_search’ shortcode to create a quick search feature with a placeholder text, a price filter, and a target attribute to control link behavior.

[woof_quick_search placeholder="Search products..." price_filter=1 target="_self"]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_quick_search] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_quick_search', array($this, 'quick_search'));

Shortcode PHP function:

function quick_search($atts) {
        
        $data = (shortcode_atts(array(
                    'short_id' => '0000', /* this is needed when using several data files now it is not used */
                    'preload' => 1, /* download a file  with the page = 1    file download by click =0 */
                    'placeholder' => esc_html__('Text search', 'woocommerce-products-filter'),
                    'price_filter' => 0, /* show price filter  1 or 0 ( only for extended filter ) */
                    'extended_filter' => 0, /* use  extend filter(alaSQL) with special template  1 or 0 */
                    'target' => '_blank', /* link behavior */
                    'reset_btn' => 1, /* show reset btn   1 or 0 ( only for extended filter ) */
                    'add_filters' => '', /* [drop-down|multi-drop-down|checkbox|radio] example  drop-down:product_cat,multi-drop-down:pa_size ( only for extended filter ) */
                    'filter_title' => '', /* Example "product_cat:Type,pa_size:Color of the item" ( only for extended filter ) */
                    'term_logic' => '', /* example  pa_color:AND,product_cat:OR ( only for extended filter ) */
                    'tax_logic' => 'AND', /*  logic  beetwin taxonomies  AND or OR ( only for extended filter ) */
                    'text_group_logic' => 'AND', /* logic for a few words, all words must be found=AND   [AND | OR}

Code file location:

woocommerce-products-filter/woocommerce-products-filter/ext/quick_search/index.php

Woocommerce Products Filter [woof_quick_search_results] Shortcode

The Woocommerce Products Filter (WOOF) shortcode is designed to quickly display search results. This shortcode generates a list of products based on the user’s search criteria, with the ability to customize the number of results per page, the display template, and the order of results. Additionally, it allows for template changes for mobile displays. The shortcode also supports overriding default views with custom ones.

Shortcode: [woof_quick_search_results]

Parameters

Here is a list of all possible woof_quick_search_results shortcode parameters and attributes:

  • per_page – Determines the number of products displayed per page.
  • template_result – Defines the template used to display search results.
  • always_show_products – If set to 1, products are always shown; 0 hides them.
  • template_structure – Sets the order of product details shown in the results.
  • orderby – Establishes the sorting order of the products in the results.
  • header_text – Allows text to be added to the header of the results page.

Examples and Usage

Basic example – The following shortcode allows you to display a quick search result with default parameters.

[woof_quick_search_results /]

Advanced examples

1. Display a quick search result with 15 products per page, using the list_2 template, always showing products, with the structure including image, title, price, and SKU, ordered by price in descending order, and a custom header text.

[woof_quick_search_results per_page=15 template_result=list_2 always_show_products=1 template_structure=img,title,price,sku orderby=price-desc header_text="Your Custom Header Text" /]

2. Display a quick search result with 20 products per page, using the grid_1 template, not always showing products, with the structure including only image and title, ordered by title in ascending order, and no header text.

[woof_quick_search_results per_page=20 template_result=grid_1 always_show_products=0 template_structure=img,title orderby=title-asc /]

3. Display a quick search result with 10 products per page, using the list_3 template, always showing products, with the structure including image, title, price, SKU, and key words, ordered by SKU in ascending order, and a custom header text.

[woof_quick_search_results per_page=10 template_result=list_3 always_show_products=1 template_structure=img,title,price,sku,key_words orderby=sku-asc header_text="Your Custom Header Text" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_quick_search_results] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_quick_search_results', array($this, 'quick_search_result'));

Shortcode PHP function:

function quick_search_result($atts) {
        
        $data = (shortcode_atts(array(
                    'per_page' => 12,
                    'template_result' => 'list_1',
                    'always_show_products' => 1,
                    'template_structure' => 'img,title,price,sku,key_words',
                    'orderby' => 'title-asc',
                    'header_text' => "",
                        ), $atts));
        $data = apply_filters('woof_qs_shortcode_data', $data); // possibility to change a template for example for a mobile
        WOOF_REQUEST::set('woof_qt_extended', $data['template_result']);
        $all_data = array();
        $all_data['data'] = $data;
        if (file_exists($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_quick_search_results.php')) {
            return woof()->render_html($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_quick_search_results.php', $all_data);
        }
        return woof()->render_html($this->get_ext_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_quick_search_results.php', $all_data);
    }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/ext/quick_search/index.php

Woocommerce Products Filter [woof_slideout] Shortcode

The Woocommerce Products Filter (WOOF) shortcode is a dynamic feature that enables a slide-out filter panel on your WooCommerce site. This shortcode adjusts the filter panel’s image, action, location, speed, offset, dimensions, and mobile behavior. It also allows for custom text and class additions. The filter panel can be set to appear on page load and its visibility can be controlled based on the device type. Unique styles can be applied to each instance with a unique key. The shortcode also supports content override for advanced customization.

Shortcode: [woof_slideout]

Parameters

Here is a list of all possible woof_slideout shortcode parameters and attributes:

  • image – Defines the image used in the slideout filter.
  • image_h – Sets the height of the image in the filter.
  • image_w – Sets the width of the image in the filter.
  • action – Determines the action that triggers the filter; click or hover.
  • location – Sets the position of the filter; left or right.
  • speed – Determines the speed of the slideout action.
  • offset – Sets the distance of the filter from the top of the page.
  • onloadslideout – Controls whether the filter is open or closed on page load.
  • mobile_behavior – Sets the behavior of the filter on mobile devices.
  • width – Defines the width of the slideout filter.
  • height – Defines the height of the slideout filter.
  • text – Determines the text displayed on the filter button.
  • class – Allows for the addition of custom CSS class to the filter.

Examples and Usage

Basic Example – Display a slideout filter with default settings.

[woof_slideout]

Advanced Examples

Display a slideout filter with a custom image and action triggered by hover instead of click.

[woof_slideout image="http://example.com/custom-image.png" action="hover"]

Customize the slideout filter’s position, speed, offset, and behavior on mobile devices. Here, the filter is positioned on the left, slides out at a speed of 200, has an offset of 150px, and is disabled on mobile devices.

[woof_slideout location="left" speed="200" offset="150px" mobile_behavior="1"]

Customize the slideout filter’s width, height, and text. Here, the filter has a width of 300px, a height of 500px, and displays “Custom Filter” as text.

[woof_slideout width="300px" height="500px" text="Custom Filter"]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_slideout] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("woof_slideout", array($this, "woof_slideout"));

Shortcode PHP function:

function woof_slideout($atts, $content) {

        $image = $this->get_ext_link() . 'img' . DIRECTORY_SEPARATOR . 'filter.png';
        if (isset($this->woof_settings['woof_slideout_img']) AND $this->woof_settings['woof_slideout_img']) {
            $image = $this->woof_settings['woof_slideout_img'];
        }
		$offset =  '100px';
		if (isset($this->woof_settings['woof_slideout_offset_t']) &&  isset($this->woof_settings['woof_slideout_offset'])) {
			$offset = $this->woof_settings['woof_slideout_offset'] . $this->woof_settings['woof_slideout_offset_t'];
		}
		
		$width = 'auto';
		if (isset($this->woof_settings['woof_slideout_width']) &&  isset($this->woof_settings['woof_slideout_width_t'])) {
			$width = $this->woof_settings['woof_slideout_width'] . $this->woof_settings['woof_slideout_width_t'];
		}		
		
		$height = 'auto';
		if (isset($this->woof_settings['woof_slideout_height_t']) &&  isset($this->woof_settings['woof_slideout_height'])) {
			$height = $this->woof_settings['woof_slideout_height'] . $this->woof_settings['woof_slideout_height_t'];
		}		
		
        $atts = shortcode_atts(array(
            'image' => $image,
            'image_h' => (isset($this->woof_settings['woof_slideout_img_h'])) ? $this->woof_settings['woof_slideout_img_h'] : 50,
            'image_w' => (isset($this->woof_settings['woof_slideout_img_w'])) ? $this->woof_settings['woof_slideout_img_w'] : 50,
            'action' => (isset($this->woof_settings['woof_slideout_action'])) ? $this->woof_settings['woof_slideout_action'] : 'click',
            'location' => (isset($this->woof_settings['woof_slideout_position'])) ? $this->woof_settings['woof_slideout_position'] : 'right',
            'speed' => (isset($this->woof_settings['woof_slideout_speed'])) ? $this->woof_settings['woof_slideout_speed'] : '100',
            'offset' => $offset,
            'onloadslideout' => (isset($this->woof_settings['woof_slideout_open'])) ? $this->woof_settings['woof_slideout_open'] : true,
            'mobile_behavior' => (isset($this->woof_settings['woof_slideout_mobile'])) ? $this->woof_settings['woof_slideout_mobile'] : '0',
            'width' => $width,
            'height' => $height,
            'text' => (isset($this->woof_settings['woof_slideout_txt'])) ? $this->woof_settings['woof_slideout_txt'] : esc_html__('Filter', 'woocommerce-products-filter'),
            'class' => ""
                ), $atts);

        if (!empty($content)) {
            $atts['content'] = $content;
        } else {
            $atts['content'] = "[woof]";
        }

        
        $show = true;
        if ($atts['mobile_behavior'] == 1 AND!wp_is_mobile()) {
            $show = false;
        }
        if ($atts['mobile_behavior'] == 2 AND wp_is_mobile()) {
            $show = false;
        }

        $atts['key'] = uniqid("woof_");

        WOOF_REQUEST::set('woof_slideout_styles', array(
            'key' => $atts['key'],
            'image_w' => $atts['image_w'],
            'image_h' => $atts['image_h'],
            'height' => $atts['height'],
            'width' => $atts['width'],
        ));

        if ($show) {

            if (file_exists($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_slideout.php')) {
                return woof()->render_html($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_slideout.php', $atts);
            }
            return woof()->render_html($this->get_ext_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'woof_slideout.php', $atts);
        } else {
            return "";
        }
    }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/ext/slideout/index.php

Woocommerce Products Filter [woof_step] Shortcode

The Woocommerce Products Filter (WOOF) shortcode is a powerful tool that allows you to customize product filtering on your Woocommerce store. This shortcode accepts various parameters, including ‘taxonomies’, ‘tax_only’, ‘tax_exclude’, ‘by_only’, ‘autohide’, ‘redirect’, ‘sid’, ‘dynamic_recount’, ‘by_step’, ‘hide’, ‘autosubmit’, ‘next_btn_txt’, ‘prev_btn_txt’, ‘filter_type’, ‘selector’, and ‘img_behavior’. It dynamically generates a filter form based on these parameters, allowing customers to narrow down their product search according to their preferences.

Shortcode: [woof_step]

Parameters

Here is a list of all possible woof_step shortcode parameters and attributes:

  • taxonomies – Defines the taxonomies to be filtered.
  • tax_only – Filters only the specified taxonomies.
  • tax_exclude – Excludes certain taxonomies from the filter.
  • by_only – Filters only by certain parameters.
  • autohide – Hides the filter when not in use.
  • redirect – Redirects the user after applying the filter.
  • sid – Specifies a unique identifier for the session.
  • dynamic_recount – Automatically recounts the number of items after filtering.
  • by_step – Allows step-wise filtering.
  • hide – Hides the filter by default.
  • autosubmit – Automatically submits the filter.
  • next_btn_txt – Customizes the text for the ‘Next’ button.
  • prev_btn_txt – Customizes the text for the ‘Back’ button.
  • filter_type – Specifies the type of filter to be used.
  • selector – Specifies the CSS selector for the filter.
  • img_behavior – Defines the behavior of images in the filter.
  • images – Specifies the images to be used in the filter.

Examples and Usage

Basic example – Display a WooCommerce product filter with default settings

[woof_step /]

Advanced examples

Display a WooCommerce product filter with specific taxonomies, and enable the autohide feature.

[woof_step taxonomies="product_cat,product_tag" autohide=1 /]

Display a WooCommerce product filter with specific taxonomies, enable the autohide feature, and redirect to a specific page after submission.

[woof_step taxonomies="product_cat,product_tag" autohide=1 redirect="http://yourwebsite.com/redirect-page" /]

Display a WooCommerce product filter with specific taxonomies, enable the autohide feature, redirect to a specific page after submission, and change the text of the next and previous buttons.

[woof_step taxonomies="product_cat,product_tag" autohide=1 redirect="http://yourwebsite.com/redirect-page" next_btn_txt="Proceed" prev_btn_txt="Go Back" /]

Display a WooCommerce product filter with specific taxonomies, enable the autohide feature, redirect to a specific page after submission, change the text of the next and previous buttons, and specify a custom CSS selector.

[woof_step taxonomies="product_cat,product_tag" autohide=1 redirect="http://yourwebsite.com/redirect-page" next_btn_txt="Proceed" prev_btn_txt="Go Back" selector=".my_custom_selector" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_step] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("woof_step", array($this, 'woof_step'));

Shortcode PHP function:

function woof_step($args) {
        $shortcode_txt = "";
        if (isset($args['taxonomies'])) {
            $shortcode_txt .= " taxonomies=" . $args['taxonomies'];
        }
        if (isset($args['tax_only'])) {
            $shortcode_txt .= " tax_only=" . $args['tax_only'];
        }

        if (isset($args['tax_exclude'])) {
            $shortcode_txt .= " tax_exclude=" . $args['tax_exclude'];
        }

        if (isset($args['by_only'])) {
            $shortcode_txt .= " by_only=" . $args['by_only'];
        }

        if (isset($args['autohide'])) {
            $shortcode_txt .= " autohide=" . $args['autohide'];
        }

        if (isset($args['redirect'])) {
            $shortcode_txt .= " redirect=" . $args['redirect'];
        }

        if (isset($args['sid'])) {
            $shortcode_txt .= " sid=" . $args['sid'];
        }
        if (isset($args['dynamic_recount'])) {
            $shortcode_txt .= " dynamic_recount=" . $args['dynamic_recount'];
        }
        if (isset($args["by_step"])) {
            $shortcode_txt .= " by_step=" . $args["by_step"];
        } else {
            $shortcode_txt .= " by_step=''";
        }

        $data["hide"] = 1;
        if (isset($args['hide'])) {
            $data["hide"] = $args['hide'];
        }

        $data["autosubmit"] = 0;
        if (isset($args['autosubmit'])) {
            $data["autosubmit"] = $args['autosubmit'];
        }


        $data["next_btn_txt"] = esc_html__('Next', 'woocommerce-products-filter');
        if (isset($args["next_btn_txt"])) {
            $data["next_btn_txt"] = $args["next_btn_txt"];
        }
        $data["prev_btn_txt"] = esc_html__('Back', 'woocommerce-products-filter');
        if (isset($args["prev_btn_txt"])) {
            $data["prev_btn_txt"] = $args["prev_btn_txt"];
        }
        $data["filter_type"] = 1;
        if (isset($args["filter_type"])) {
            $data["filter_type"] = intval($args["filter_type"]);
            if ($data["filter_type"] > 2) {
                $data["filter_type"] = 2;
            }
        }
        
        $data["selector"] = ".woof_step";
        if (isset($args["selector"])) {
            $data["selector"] = $args["selector"];
        } 
        $data["img_behavior"] = "append";
        if (isset($args["img_behavior"])) {
            $data["img_behavior"] = $args["img_behavior"];
        } 
        
        $data["images"] = array();
        if (isset($args['images'])) {
            $size=apply_filters("woof_step_filter_img_size",'thumbnail');
            $image_arr= explode(",",$args['images']);
            foreach($image_arr as $image_item){
                $image_item=explode(":",$image_item,2);
                if(count($image_item)==2){
                    $url=wp_get_attachment_image_url(intval($image_item[1]),$size);
                    if($url){
                        $data["images"][trim($image_item[0])]= '<img src="'.$url.'" class="woof_step_filter_image woof_step_filter_image_'.trim($image_item[0]).'" >';
                    }
                }
                
            }

        }


        $data["shortcode_woof"] = "[woof ajax_redraw=1 autosubmit=0  " . $shortcode_txt . "]";

        
        if(file_exists($this->get_ext_override_path(). 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'step_filter.php')){
            return woof()->render_html($this->get_ext_override_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcodes' . DIRECTORY_SEPARATOR . 'step_filter.php', $data);
        }           
        return woof()->render_html($this->get_ext_path() . 'views' . DIRECTORY_SEPARATOR . 'shortcode' . DIRECTORY_SEPARATOR . 'step_filter.php', $data);
    }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/ext/step_filer/index.php

Woocommerce Products Filter [woof] Shortcode

The Woocommerce Products Filter (WOOF) shortcode allows users to customize product filters on their WooCommerce site. It provides options to set taxonomies, exclude specific terms, and define mobile mode. It also enables users to specify which taxonomies to display, hide empty taxonomies, and choose a specific skin for the filter. Additional features include setting autohide, redirect, and start filtering button text. Shortcode: [woof] Moreover, it allows users to exclude certain taxonomies, define the autosubmit option, hide terms count, and set the button position. Lastly, it offers options for dynamic recount, price filter and step filter. Shortcode: [woof]

Shortcode: [woof]

Parameters

Here is a list of all possible woof shortcode parameters and attributes:

  • taxonomies – Specifies additional taxonomies for the product filter.
  • excluded_terms – Defines terms that should be excluded from the filter.
  • mobile_mode – Enables or disables mobile mode for the filter.
  • tax_only – Filters products based on specified taxonomies only.
  • skin – Sets the CSS style for the filter.
  • sid – Sets a unique identifier for the filter.
  • autohide – Controls whether the filter should hide automatically.
  • redirect – Specifies a redirection URL after filter submission.
  • start_filtering_btn – Enables or disables the filter button.
  • start_filtering_btn_txt – Sets the text for the filter button.
  • tax_exclude – Excludes specified taxonomies from the filter.
  • by_only – Filters products based on specified attributes only.
  • autosubmit – Controls whether the filter should submit automatically.
  • hide_terms_count – Hides the count of terms in the filter.
  • ajax_redraw – Enables or disables AJAX redraw for the filter.
  • btn_position – Sets the position of the filter button.
  • dynamic_recount – Enables or disables dynamic recount of products in the filter.
  • by_step – Sets the step for the filter.
  • swoof_slug – Sets a unique slug for the filter.
  • items_order – Sets the order of items in the filter.
  • viewtypes – Sets the view types for the filter.

Examples and Usage

Basic example – The following shortcode displays the WooCommerce Products Filter (WOOF) without any specific parameters, hence it will use the default settings.

[woof /]

Advanced examples

Displaying the WooCommerce Products Filter (WOOF) with specific taxonomies. This will only show filters for the specified taxonomies, in this case, ‘product_cat’ and ‘product_tag’.

[woof taxonomies="product_cat,product_tag" /]

Using the shortcode to exclude specific terms. This will exclude the terms with the IDs 10 and 20 from the filter.

[woof excluded_terms="10,20" /]

Using the shortcode to enable mobile mode. This will make the filter more user-friendly for mobile users.

[woof mobile_mode="1" /]

Using the shortcode to specify taxonomies to be shown only. This will only show filters for the specified taxonomies, in this case, ‘product_cat’.

[woof tax_only="product_cat" /]

Using the shortcode to apply a specific skin. This will apply the ‘flat’ skin to the filter.

[woof skin="flat" /]

Using the shortcode to enable autohide. This will hide the filter until the user clicks on the ‘Show products filter form’ button.

[woof autohide="1" /]

Using the shortcode to enable autosubmit. This will automatically submit the filter once a user makes a selection.

[woof autosubmit="1" /]

Using the shortcode to hide terms count. This will hide the count of products for each term in the filter.

[woof hide_terms_count="1" /]

Using the shortcode to enable AJAX redraw. This will redraw the filter without reloading the page when a user makes a selection.

[woof ajax_redraw="1" /]

Using the shortcode to specify the button position. This will place the ‘Show products filter form’ button at the bottom.

[woof btn_position="b" /]

Using the shortcode to enable dynamic recount. This will dynamically recount the number of products for each term in the filter based on the user’s selections.

[woof dynamic_recount="1" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof', array($this, 'woof_shortcode'));

Shortcode PHP function:

function woof_shortcode($atts) {
            $args = array();
            //this for synhronizating shortcode woof_products if its has attribute taxonomies

            if (isset($atts['taxonomies'])) {
                $args['additional_taxes'] = apply_filters('woof_set_shortcode_taxonomyattr_behaviour', $atts['taxonomies']);
            } else {
                $args['additional_taxes'] = '';
            }

            //by hands excluded terms directly in [woof] shortcode
            WOOF_REQUEST::del('woof_shortcode_excluded_terms');
            if (isset($atts['excluded_terms'])) {
                WOOF_REQUEST::set('woof_shortcode_excluded_terms', $atts['excluded_terms']);
            }

            if (isset($atts['mobile_mode'])) {
                $args['mobile_mode'] = $atts['mobile_mode'];
            }

            //+++
            $taxonomies = $this->get_taxonomies();
            $allow_taxonomies = (array) (isset($this->settings['tax']) ? $this->settings['tax'] : array());
            if (isset($atts['tax_only'])) {
                $args['tax_only'] = explode(',', $atts['tax_only']);
                $args['tax_only'] = array_map('trim', $args['tax_only']);
            } else {
                $args['tax_only'] = array();
            }
            $args['woof_settings'] = get_option('woof_settings', array());

            //overrides taxonomy display with shortcode attributes
            foreach ($args['tax_only'] as $tax_filter_key) {
                if (!isset($allow_taxonomies[$tax_filter_key])) {
                    $allow_taxonomies[$tax_filter_key] = 1;
                    $this->settings['tax'][$tax_filter_key] = 1;
                    $args['woof_settings']['tax'][$tax_filter_key] = 1;
                }
            }
            //+++
            $args['taxonomies'] = array();
            $hide_empty = (bool) get_option('woof_hide_dynamic_empty_pos', 0);
            if (!empty($taxonomies)) {
                foreach ($taxonomies as $tax_key => $tax) {
                    if (!in_array($tax_key, array_keys($allow_taxonomies))) {
                        continue;
                    }
                    //+++

                    $args['taxonomies_info'][$tax_key] = $tax;
                    $args['taxonomies'][$tax_key] = WOOF_HELPER::get_terms($tax_key, $hide_empty);
                    //show only subcategories if is_really_current_term_exists
                    if ($this->is_really_current_term_exists()) {
                        $t = $this->get_really_current_term();
                        if ($tax_key == $t->taxonomy) {
                            if (isset($args['taxonomies'][$tax_key][$t->term_id])) {
                                $args['taxonomies'][$tax_key] = $args['taxonomies'][$tax_key][$t->term_id]['childs'];
                            } else {
                                if ($t->parent != 0) {
                                    $parent = get_term($t->parent, $tax_key);
                                    $parents_ids = array();
                                    $parents_ids[] = $parent->term_id;
                                    while ($parent->parent != 0) {
                                        $parent = get_term_by('id', $parent->parent, $tax_key);
                                        $parents_ids[] = $parent->term_id;
                                    }
                                    $parents_ids = array_reverse($parents_ids);
                                    //***
                                    $tmp = $args['taxonomies'][$tax_key];
                                    foreach ($parents_ids as $id) {
                                        $tmp = $tmp[$id]['childs'];
                                    }
                                    if (isset($tmp[$t->term_id])) {
                                        $args['taxonomies'][$tax_key] = $tmp[$t->term_id]['childs'];
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                $args['taxonomies'] = array();
            }

            //***
            if (isset($atts['skin'])) {
                wp_enqueue_style('woof_skin_' . $atts['skin'], WOOF_LINK . 'css/shortcode_skins/' . $atts['skin'] . '.css', array(), WOOF_VERSION);
            }
            //***

            if (isset($atts['sid'])) {
                $args['sid'] = $atts['sid'];
                wp_enqueue_script('woof_sid', WOOF_LINK . 'js/woof_sid.js', array('jquery'), WOOF_VERSION);
            }


            if (isset($atts['autohide'])) {
                $args['autohide'] = $atts['autohide'];
            } else {
                $args['autohide'] = 0;
            }

            if (isset($atts['redirect'])) {
                $args['redirect'] = $atts['redirect'];
            } else {
                $args['redirect'] = '';
            }

            if (isset($atts['start_filtering_btn'])) {
                $args['start_filtering_btn'] = intval($atts['start_filtering_btn']);
            } else {
                $args['start_filtering_btn'] = 0;
            }

            if (isset($atts['start_filtering_btn_txt'])) {
                $args['woof_start_filtering_btn_txt'] = $atts['start_filtering_btn_txt'];
            } else {
                $args['woof_start_filtering_btn_txt'] = apply_filters('woof_start_filtering_btn_txt', esc_html__('Show products filter form', 'woocommerce-products-filter'));
            }


            if (isset($atts['tax_exclude'])) {
                $args['tax_exclude'] = explode(',', $atts['tax_exclude']);
                $args['tax_exclude'] = array_map('trim', $args['tax_exclude']);
            } else {
                $args['tax_exclude'] = array();
            }

            if (isset($atts['by_only'])) {
                $args['by_only'] = explode(',', $atts['by_only']);
                $args['by_only'] = array_map('trim', $args['by_only']);
            } else {
                $args['by_only'] = array();
            }


            if (isset($atts['autosubmit']) AND $atts['autosubmit'] != -1) {
                $args['autosubmit'] = $atts['autosubmit'];
            } else {
                $args['autosubmit'] = get_option('woof_autosubmit', 0);
            }


            WOOF_REQUEST::set('hide_terms_count_txt_short', -1);
            if (isset($atts['hide_terms_count'])) {
                WOOF_REQUEST::set('hide_terms_count_txt_short', intval($atts['hide_terms_count']));
            }

            if (isset($atts['ajax_redraw'])) {
                $args['ajax_redraw'] = $atts['ajax_redraw'];
            } else {
                $args['ajax_redraw'] = 0;
            }
            if (isset($atts['btn_position'])) {
                $args['btn_position'] = $atts['btn_position'];
            } else {
                $args['btn_position'] = 'b';
            }
            if (isset($atts['dynamic_recount'])) {
                $args['dynamic_recount'] = $atts['dynamic_recount'];
            } else {
                $args['dynamic_recount'] = -1;
            }

            $args['price_filter'] = 0;
            if (isset($this->settings['by_price']['show'])) {
                $args['price_filter'] = (int) $this->settings['by_price']['show'];
            }

            if (isset($atts['by_step'])) {
                $args['by_step'] = $atts['by_step'];
            }

            //for front builder
            if (isset($atts['swoof_slug']) AND !empty($atts['swoof_slug'])) {
                $args['swoof_slug'] = $atts['swoof_slug'];
            }

            //***
            $args['show_woof_edit_view'] = 0;
            if (current_user_can('create_users')) {
                $args['show_woof_edit_view'] = isset($this->settings['show_woof_edit_view']) ? (int) $this->settings['show_woof_edit_view'] : 0;
            }

            //lets assemble shortcode txt for ajax mode for data-shortcode in woof.php
            WOOF_REQUEST::set('woof_shortcode_txt', 'woof ');
            if (!empty($atts)) {
                foreach ($atts as $key => $value) {
                    if (($key == 'tax_only' OR $key == 'by_only' OR $key == 'tax_exclude') AND empty($value)) {
                        continue;
                    }

                    WOOF_REQUEST::set('woof_shortcode_txt', WOOF_REQUEST::get('woof_shortcode_txt') . $key . "='" . (is_array($value) ? explode(',', $value) : $value) . "' ");
                }
            }

            //+++

            if (isset($atts['items_order'])) {
                $items_order = explode(',', $atts['items_order']);
                add_filter('woof_custom_filter_items_order', function ($order)use ($items_order) {
                    return $items_order;
                });
            }

            //+++

            $args['shortcode_atts'] = $atts;

            //+++

            $genuine_settings = woof()->settings; //do manipulations on the fly for this filter instance only

            if (isset($atts['viewtypes'])) {
                $viewtypes = explode(',', $atts['viewtypes']);
                foreach ($viewtypes as $pair) {
                    $val = explode(':', $pair);
                    if (isset(woof()->settings['tax_type'][$val[0]])) {
                        woof()->settings['tax_type'][$val[0]] = $val[1];
                    }
                }
            }

            //use with great care, #1 for filter sections options
            $args['woof_settings'] = woof()->settings = apply_filters('woof_modify_settings_before_action', woof()->settings, $atts);

            //in this place can be overloaded all settings personally for the current filter instance
            if (isset($atts['by_only']) AND !empty($atts['by_only'])) {
                $by_only = explode(',', $atts['by_only']);
                if (is_array($by_only)) {
                    foreach ($by_only as $by_only_key) {
                        $val = 1;

                        //exclusive exception for price
                        if ($by_only_key === 'by_price') {
                            $val = intval(woof()->settings[$by_only_key]['show']);
                        }

                        //hook woof_regulate_by_only_show is need here only for price filter because its view depends of this value: 1,2,3,4,5
                        woof()->settings[$by_only_key]['show'] = apply_filters('woof_regulate_by_only_show', $val, $by_only_key);
                    }
                }
            }

            $html = $this->render_html(WOOF_PATH . 'views/woof.php', apply_filters('woof_filter_shortcode_args', $args));
            woof()->settings = $genuine_settings;

            return $html;
        }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/index.php

Woocommerce Products Filter [woof_btn] Shortcode

The Woocommerce Products Filter (WOOF) shortcode is a powerful tool for enhancing user experience. This shortcode, when implemented, displays a filter button on your WooCommerce site. The ‘show_btn’ function calls a PHP file that renders the button, making product searches more streamlined for users.

Shortcode: [woof_btn]

Examples and Usage

Basic example – The WOOF – WooCommerce Products Filter plugin allows you to display a button by using the ‘woof_btn’ shortcode.

[woof_btn id="1" /]

Here, the shortcode is displaying the button with the id of 1. The ‘id’ parameter is used to specify the button you want to display.

Advanced examples

It’s possible to customize the appearance and functionality of the button further by using additional parameters/attributes within the shortcode.

[woof_btn id="1" class="custom-class" style="color:blue;" /]

In this example, the ‘class’ parameter is used to add a custom CSS class to the button, and the ‘style’ parameter is used to apply inline CSS to the button. Here, the button text color is set to blue.

[woof_btn id="1" text="Filter Products" /]

In this example, the ‘text’ parameter is used to specify the text displayed on the button. Here, the button will display the text ‘Filter Products’.

These are just a few examples of how you can use the ‘woof_btn’ shortcode to display and customize a button with the WOOF – WooCommerce Products Filter plugin.

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_btn] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_btn', array($this, 'show_btn'));

Shortcode PHP function:

function show_btn($atts) {
            return $this->render_html(WOOF_PATH . 'views/shortcodes/woof_show_btn.php', $atts);
        }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/index.php

Woocommerce Products Filter [woof_mobile] Shortcode

The Woocommerce Products Filter shortcode is a dynamic tool designed to display a mobile button. It’s specifically programmed to show only when the website is accessed via a mobile device. This shortcode, when implemented, calls the ‘show_mobile_btn’ function. This function checks if the website is being viewed on a mobile device. If so, it renders a mobile-specific button.

Shortcode: [woof_mobile]

Examples and Usage

Basic example – The following shortcode will display the mobile button if the user is accessing the website through a mobile device.

[woof_mobile /]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_mobile] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_mobile', array($this, 'show_mobile_btn'));

Shortcode PHP function:

function show_mobile_btn($atts) {
            if (wp_is_mobile()) {
                return $this->render_html(WOOF_PATH . 'views/shortcodes/woof_mobile_btn.php', $atts);
            }

            return "";
        }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/index.php

Woocommerce Products Filter [woof_products] Shortcode

The Woocommerce Products Filter (WOOF) plugin shortcode is a powerful tool that allows you to create a customized product search feature. It uses different parameters to filter and order products based on user input. It supports various filters like product categories, attributes, tags, custom taxonomies, and price. Additionally, it provides options for product sorting and pagination. The shortcode is highly customizable, enabling you to adjust the columns, order, and behavior to suit your needs. It also offers AJAX support, improving the user experience by providing instant results without page reloads. This shortcode is an essential tool for enhancing product navigation and search on your WooCommerce store.

Shortcode: [woof_products]

Parameters

Here is a list of all possible woof_products shortcode parameters and attributes:

  • columns – sets the number of columns in the products grid
  • orderby – sets the order criteria of the products
  • order – sets the order direction (ascending or descending)
  • page – specifies the page number for pagination
  • per_page – defines the number of products per page
  • is_ajax – if set to 1, the products list will update without page reload
  • taxonomies – specifies the product taxonomy for filtering
  • sid – not clearly defined in the provided code
  • behavior – sets a specific behavior like ‘recent’ for recent products
  • custom_tpl – path to a custom template for the products layout
  • tpl_index – index of a template extension
  • predict_ids_and_continue – if true, predicts product IDs and continues execution
  • get_args_only – if true, only returns the query arguments
  • product_ids – a comma-separated list of specific product IDs to display
  • post__in – a comma-separated list of post IDs to include in the query
  • display_on_search – if set to 1, only displays products on search results page

Examples and Usage

Basic example – Displaying products in a grid format with 4 columns.

[woof_products columns=4 /]

Advanced examples

Displaying products in a list format with 2 columns, sorted by price in ascending order, and only showing 10 products per page.

[woof_products columns=2 orderby='price' order='asc' per_page=10 /]

Displaying products from specific categories (e.g., category IDs 5 and 10), with custom template, and showing only the products that are on sale.

[woof_products taxonomies='product_cat:5,10' custom_tpl='my_custom_template' behavior='onsales' /]

Displaying products with a specific attribute (e.g., color: blue and size: large).

[woof_products taxonomies='pa_color:blue,pa_size:large' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_products] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_products', array($this, 'woof_products'));

Shortcode PHP function:

function woof_products($atts, $is_prediction = false) {
        WOOF_REQUEST::set('woof_products_doing', 1);
        $shortcode_txt = 'woof_products';
        if (!empty($atts) AND is_array($atts)) {
            foreach ($atts as $key => $value) {
                $shortcode_txt .= ' ' . $key . '=' . $value;
            }
        }
        //***
        $data = $this->get_request_data();
        $catalog_orderby = $this->get_catalog_orderby(isset($data['orderby']) ? $data['orderby'] : '');

        //https://gist.github.com/mikejolley/1622323
        extract(shortcode_atts(array(
            'columns' => apply_filters('loop_shop_columns', 4),
            'orderby' => 'no',
            'order' => 'no',
            'page' => 1,
            'per_page' => 0,
            'is_ajax' => 0,
            'taxonomies' => '',
            'sid' => '',
            'behavior' => '', //recent
            'custom_tpl' => '', //path like: wp-content/themes/my_theme/woo_tpl_1.php
            'tpl_index' => '', //index of any template extension
            'predict_ids_and_continue' => false,
            'get_args_only' => false,
            'shortcode' => '',
            'product_ids' => "",
            'post__in' => "",
            'display_on_search' => 0,
                        ), $atts));

        $order_by_defined_in_atts = false;
        if ($orderby == 'no') {
            $orderby = $catalog_orderby['orderby'];
            $order = $catalog_orderby['order'];
        } elseif ($orderby == 'price' OR $orderby == 'price-desc') {
            $catalog_orderby = $this->get_catalog_orderby(isset($orderby) ? $orderby : '');
        } else {
            $order_by_defined_in_atts = true;
        }

        //***
        //this needs just for AJAX mode for shortcode [woof] in woof_draw_products()
        WOOF_REQUEST::set('woof_additional_taxonomies_string', $taxonomies);

        // fix visibility
        $tax_query = array();
        if (empty($product_ids)) {
            $tax_query = $this->get_tax_query($taxonomies);
        }

        if (version_compare(WOOCOMMERCE_VERSION, '3.0', '>=') AND version_compare(WOOCOMMERCE_VERSION, '3.3', '<')) {
            $tax_query = $this->listen_catalog_visibility($tax_query);
        } elseif (version_compare(WOOCOMMERCE_VERSION, '3.3', '>=')) {         // woo3.3
            $search = false;
            if ($this->is_isset_in_request_data($this->get_swoof_search_slug()) && count($data) > 1) {
                $search = true;
            }

            $tax_query = $this->product_visibility_not_in($tax_query, $this->generate_visibility_keys($search));
        }
        //+++
        //+++

        $args = array(
            'post_type' => array('product'/* ,'product_variation' */),
            'post_status' => 'publish',
            'orderby' => $orderby,
            'order' => $order,
            'tax_query' => $tax_query,
            'wc_query' => 'product_query'//key to find this  query
        );
        if (empty($product_ids)) {
            $args['meta_query'] = $this->get_meta_query();
            if ($post__in) {
                $args['post__in'] = explode(",", $post__in);
            }
        } else {
            $args['post__in'] = explode(",", $product_ids);
        }

        if ($per_page > 0) {
            $args['posts_per_page'] = $per_page;
        } else {
            if (isset($this->settings['per_page']) && intval($this->settings['per_page']) > 0) {
                $args['posts_per_page'] = intval($this->settings['per_page']);
            }

            //compatibility for woocommerce-products-per-page
            if (class_exists('Woocommerce_Products_Per_Page')) {
                $args['posts_per_page'] = $this->get_wppp_per_page();
            }
        }

        //Display Product for WooCommerce compatibility
        if (WOOF_REQUEST::isset('perpage')) {
            $args['posts_per_page'] = intval(WOOF_REQUEST::get('perpage'));
        }

        //if smth wrong, set default per page option
        if (!isset($args['posts_per_page']) OR empty($args['posts_per_page'])) {
            if ($this->get_option('per_page') > 0) {
                $args['posts_per_page'] = $this->get_option('per_page');
            } else {
                $args['posts_per_page'] = get_option('posts_per_page');
            }
        }

        //***
        if (!$order_by_defined_in_atts) {
            if (!empty($catalog_orderby['meta_key'])) {
                $args['meta_key'] = $catalog_orderby['meta_key'];
                $args['orderby'] = $catalog_orderby['orderby'];
                if (!empty($catalog_orderby['order'])) {
                    $args['order'] = $catalog_orderby['order'];
                }
            } else {
                $args['orderby'] = $catalog_orderby['orderby'];
                if (!empty($catalog_orderby['order'])) {
                    $args['order'] = $catalog_orderby['order'];
                }
            }
        }
        //print_r($args);
        //+++
        $pp = $page;
        if (get_query_var('page')) {
            $pp = get_query_var('page');
        }
        if (get_query_var('paged')) {
            $pp = get_query_var('paged');
        }

        if ($pp > 1) {
            $args['paged'] = $pp;
        } else {
            $args['paged'] = ((get_query_var('page')) ? get_query_var('page') : $page);
        }
        //+++

        if (!empty($behavior)) {
            switch ($behavior) {
                case 'recent':
                    $args['orderby'] = 'date';
                    $args['order'] = 'desc';
                    break;

                default:
                    break;
            }
        }
        //***
        $wr = $args;

        global $products, $wp_query;
        //***
        $tax_relations = apply_filters('woof_main_query_tax_relations', array());
        if (!empty($tax_relations)) {
            $tax_query = $wr['tax_query'];
            foreach ($tax_query as $key => $value) {
                if (isset($value['taxonomy'])) {
                    if (in_array($value['taxonomy'], array_keys($tax_relations))) {
                        if (count($tax_query[$key]['terms'])) {
                            $tax_query[$key]['operator'] = $tax_relations[$value['taxonomy']];
                            $tax_query[$key]['include_children'] = 0;
                        }
                    }
                }
            }

            $wr['tax_query'] = $tax_query;
        }
        //***

        $wr = apply_filters('woof_products_query', $wr);

        //***

        if ($get_args_only) {
            WOOF_REQUEST::set('woof_query_args', $wr);
            return $wr;
        }
        $hide_products = false;
        if ($display_on_search) {
            $hide_products = true;
            $get_array = $this->get_request_data();
            //var_dump($real_query);
            if (isset($this->settings['items_order'])) {
                $key_array = explode(',', $this->settings['items_order']);
                $by_only_array = array('woof_text', 'stock', 'onsales', 'woof_sku', 'product_visibility', 'min_price', 'max_price');
                $tax_array = array_keys($this->settings['excluded_terms']);
                $key_array = array_merge($by_only_array, $key_array, $tax_array);
                $real_query = array_intersect(array_keys($get_array), $key_array);
                if (count($real_query)) {
                    $hide_products = false;
                }
                //var_dump($key_array);
                if (isset($this->settings['meta_filter'])) {
                    if (!is_array($this->settings['meta_filter'])) {
                        $this->settings['meta_filter'] = array();
                    }
                    foreach ($this->settings['meta_filter'] as $item) {
                        $key = $item['search_view'] . "_" . $item['meta_key'];
                        if (in_array($key, array_keys($get_array))) {
                            $hide_products = false;
                        }
                    }
                }
            }
        }

        if (!$is_prediction) {
            $wp_query = $products = new WP_Query($wr);
            WOOF_REQUEST::set('woof_wp_query', $wp_query);
            WOOF_REQUEST::set('woof_wp_query_found_posts', $wp_query->found_posts);

            if ($predict_ids_and_continue) {
                WOOF_REQUEST::set('predict_ids_and_continue', 1);
                WOOF_REQUEST::set('woof_wp_query_ids', new WP_Query(array_merge($wr, array('fields' => 'ids'))));
                WOOF_REQUEST::set('woof_wp_query_ids', WOOF_REQUEST::get('woof_wp_query_ids')->posts);
            }
        } else {
            WOOF_REQUEST::set('woof_wp_query_ids', new WP_Query(array_merge($wr, array('fields' => 'ids'))));
            WOOF_REQUEST::set('woof_wp_query_ids', WOOF_REQUEST::get('woof_wp_query_ids')->posts);
            return;
        }


        if ($this->get_option('listen_catalog_visibility')
                AND $this->is_isset_in_request_data($this->get_swoof_search_slug())) {
            //for wp-content\plugins\woocommerce\includes\class-wc-query.php -> $in = array( 'visible', 'search' )
            $wp_query->is_search = true;
        }

        $wp_query->is_post_type_archive = true; //we need it to display top panel with counter and order drop-down
        WOOF_REQUEST::set('woof_wp_query_args', $wr);
        //***
        ob_start();
        global $woocommerce_loop;
        $woocommerce_loop['columns'] = $columns;
        $woocommerce_loop['loop'] = 0;
        // woo3.3
        if (version_compare(WOOCOMMERCE_VERSION, '3.3', '>=')) {
            $this->set_loop_properties($products, $columns);
        }
        ?>

        <?php if ($is_ajax == 1): ?>
                <?php ?>
            <div id="woof_results_by_ajax" data-count="<?php echo intval($products->found_posts) ?>"  class="woof_results_by_ajax_shortcode" data-shortcode="<?php echo esc_attr($shortcode_txt) ?>">
                <?php
                //endif;
                //ajax compatibility
                WOOF_REQUEST::set('woof_redraw_elements', []);
                if (isset($this->settings['result_count_redraw']) AND $this->settings['result_count_redraw']) {
                    ob_start();
                    woocommerce_result_count();
                    WOOF_REQUEST::push('woof_redraw_elements', ob_get_contents(), $this->settings['result_count_redraw']);
                    ob_end_clean();
                }
                if (isset($this->settings['order_dropdown_redraw']) AND $this->settings['order_dropdown_redraw']) {
                    ob_start();
                    woocommerce_catalog_ordering();

                    WOOF_REQUEST::push('woof_redraw_elements', ob_get_contents(), $this->settings['order_dropdown_redraw']);

                    ob_end_clean();
                }
                if (isset($this->settings['per_page_redraw']) AND $this->settings['per_page_redraw']) {
                    ob_start();
                    woocommerce_pagination();

                    WOOF_REQUEST::push('woof_redraw_elements', ob_get_contents(), $this->settings['per_page_redraw']);

                    ob_end_clean();
                }
                WOOF_REQUEST::set('woof_redraw_elements', apply_filters('woof_redraw_elements_after_ajax', WOOF_REQUEST::get('woof_redraw_elements'), $products));
                //+++
                ?>
            <?php endif; ?>
            <?php
            if ($products->have_posts()) :
                add_filter('post_class', array($this, 'woo_post_class'));
                WOOF_REQUEST::set('woof_before_shop_loop_done', true);
                ?>

                <div class="woocommerce columns-<?php echo esc_attr($columns) ?> woocommerce-page woof_shortcode_output">

                    <?php
                    $show_loop_filters = true; //for attribute behavior of the shortcode
                    if (!empty($behavior)) {
                        if ($behavior == 'recent') {
                            $show_loop_filters = false;
                        }
                    }
                    // elementor  compatybility
                    if (isset($_GET['action']) AND $_GET['action'] == 'elementor') {
                        $show_loop_filters = false;
                    }
                    if (!$hide_products) {
                        if ($show_loop_filters) {
                            do_action('woocommerce_before_shop_loop');
                        }

                        //***



                        if (function_exists('woocommerce_product_loop_start')) {
                            woocommerce_product_loop_start();
                        }
                        ?>

                        <?php
                        global $woocommerce_loop;
                        $woocommerce_loop['columns'] = $columns;
                        $woocommerce_loop['loop'] = 0;

                        //+++
                        //wc_get_template('loop/loop-start.php');
                        ?>

                        <?php
                        $template_part = apply_filters('woof_template_part', 'product');
                        //products output
                        if (empty($custom_tpl) AND empty($tpl_index)) {
                            while ($products->have_posts()) : $products->the_post();
                                wc_get_template_part('content', $template_part);
                            endwhile; // end of the loop.
                        } else {
                            if (!empty($tpl_index)) {
                                //template extension drawing
                                if (isset(WOOF_EXT::$includes['applications'][$tpl_index])) {
                                    WOOF_EXT::$includes['applications'][$tpl_index]->draw($products);
                                }
                            } else {
                                $custom_tpl = str_replace('.' . pathinfo($custom_tpl, PATHINFO_EXTENSION), '', str_replace("..", "", $custom_tpl));
                                $this->render_html_e(get_theme_file_path($custom_tpl . ".php"), array(
                                    'the_products' => $products
                                ));
                            }
                        }
                        ?>

                        <?php //wc_get_template('loop/loop-end.php');                                                                                                                         ?>

                        <?php
                        //woo_pagenav(); - for wp theme canvas
                        if (function_exists('woocommerce_product_loop_end')) {
                            woocommerce_product_loop_end();
                        }
                        ?>

                        <?php
                        if ($show_loop_filters) {
                            do_action('woocommerce_after_shop_loop');
                        }
                    }
                    ?>
                </div>


                <?php
            else:
                if ($is_ajax == 1) {
                    ?>
                    <div id="woof_results_by_ajax" class="woof_results_by_ajax_shortcode" data-shortcode="<?php echo esc_attr($shortcode_txt) ?>">
                        <?php
                    }
                    ?>
                    <div class="woocommerce woocommerce-page woof_shortcode_output">

                        <?php
                        if (!$is_ajax) {
                            wc_get_template('loop/no-products-found.php');
                        } else {
                            ?>
                            <div id="woof_results_by_ajax" class="woof_results_by_ajax_shortcode" data-shortcode="<?php echo esc_attr($shortcode_txt) ?>">
                                <?php
                                wc_get_template('loop/no-products-found.php');
                                ?>
                            </div>
                            <?php
                        }
                        ?>

                    </div>
                    <?php
                    if ($is_ajax == 1) {
                        if (!get_option('woof_try_ajax', 0)) {
                            echo '</div>';
                        }
                    }

                endif;
                ?>

                <?php if ($is_ajax == 1): ?>
            <?php if (!get_option('woof_try_ajax', 0)): ?>
                    </div>

                <?php endif; ?>
            <?php endif; ?>
            <?php
            wp_reset_postdata();
            wp_reset_query();
            // woo3.3
            if (version_compare(WOOCOMMERCE_VERSION, '3.3', '>=')) {
                wc_reset_loop();
            }
            //+++

            WOOF_REQUEST::del('woof_products_doing');

            return ob_get_clean();
        }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/index.php

Woocommerce Products Filter [woof_products_ids_prediction] Shortcode

The Woocommerce Products Filter shortcode is a powerful tool that predicts product IDs. This shortcode pulls product IDs based on specific attributes, enabling efficient product filtering. It simplifies the process of predicting and retrieving product IDs, enhancing the user experience.

Shortcode: [woof_products_ids_prediction]

Examples and Usage

Basic Example – The following shortcode is a basic usage example for the woof_products_ids_prediction function. It doesn’t contain any parameters inside.

[woof_products_ids_prediction /]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_products_ids_prediction] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_products_ids_prediction', array($this, 'woof_products_ids_prediction'));

Shortcode PHP function:

function woof_products_ids_prediction($atts) {
        return $this->woof_products($atts, true);
    }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/index.php

Woocommerce Products Filter [woof_price_filter] Shortcode

The Woocommerce Products Filter (WOOF) plugin shortcode, ‘woof_price_filter’, allows you to filter products by price. It offers four types of filters: slider, select, text, and radio. You can set a minimum and maximum price range. If no range is specified, it defaults to null. The selected filter type determines the HTML rendered for the price filter.

Shortcode: [woof_price_filter]

Parameters

Here is a list of all possible woof_price_filter shortcode parameters and attributes:

  • type – defines the type of price filter, can be ‘slider’, ‘select’, ‘text’, or ‘radio’
  • range_min – sets the minimum price range for the filter
  • range_max – sets the maximum price range for the filter

Examples and Usage

Basic example – A simple usage of the woof_price_filter shortcode without any parameters.

[woof_price_filter]

Advanced examples

Using the shortcode to display a price filter with a slider type. This will present a slider to users, allowing them to easily adjust the price range they are interested in.

[woof_price_filter type="slider"]

Using the shortcode to display a price filter with a select type and defined minimum and maximum range. This will present a dropdown to users with price ranges between the defined minimum and maximum values.

[woof_price_filter type="select" range_min="10" range_max="100"]

Using the shortcode to display a price filter with a text type. This allows users to manually input their desired price range.

[woof_price_filter type="text"]

Using the shortcode to display a price filter with a radio type. This will present a set of radio buttons to users, with each button representing a different price range.

[woof_price_filter type="radio"]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_price_filter] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_price_filter', array($this, 'woof_price_filter'));

Shortcode PHP function:

function woof_price_filter($args = array()) {
            if (!is_array($args)) {
                $args = array();
            }
            $type = 'slider';
            if (isset($args['type']) AND $args['type'] == 'select') {
                $type = 'select';
            }
            if (isset($args['type']) AND $args['type'] == 'text') {
                $type = 'text';
            }
            if (isset($args['type']) AND $args['type'] == 'radio') {
                $type = 'radio';
            }
            if (!isset($args['range_min'])) {
                $args['range_min'] = null;
            }
            if (!isset($args['range_max'])) {
                $args['range_max'] = null;
            }
            return $this->render_html(WOOF_PATH . 'views/shortcodes/woof_price_filter_' . $type . '.php', $args);
        }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/index.php

Woocommerce Products Filter [woof_search_options] Shortcode

The Woocommerce Products Filter (WOOF) shortcode ‘woof_search_options’ is used to render the HTML for the search options. It calls the ‘woof_search_options’ function which takes an array of arguments and returns the rendered HTML from the ‘woof_search_options.php’ file.

Shortcode: [woof_search_options]

Examples and Usage

Basic Example – The given shortcode will render the Woocommerce Products Filter (WOOF) search options on your page.

[woof_search_options]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_search_options] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_search_options', array($this, 'woof_search_options'));

Shortcode PHP function:

function woof_search_options($args = array()) {
            return $this->render_html(WOOF_PATH . 'views/shortcodes/woof_search_options.php', array());
        }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/index.php

Woocommerce Products Filter [woof_found_count] Shortcode

The Woocommerce Products Filter (WOOF) shortcode, ‘woof_found_count’, is designed to display the total number of products found after a filter is applied on a WooCommerce site. It executes a function that renders an HTML view, showing the count of filtered products. This is beneficial for users to see their filter results at a glance.

Shortcode: [woof_found_count]

Examples and Usage

Basic example – The following shortcode is a simple example that displays the count of found products in a WooCommerce store using the Woocommerce-products-filter plugin.

[woof_found_count]

Advanced examples

While the basic usage of the ‘woof_found_count’ shortcode doesn’t require any parameters, you can extend its functionality by passing different arguments into the shortcode. Here are a few examples:

1. Display the count of found products with a custom CSS class. This allows you to style the output of the shortcode according to your needs.

[woof_found_count class="my-custom-class"]

2. Display the count of found products with a custom id. This can be useful if you want to target the output of the shortcode with JavaScript.

[woof_found_count id="my-custom-id"]

Remember, you can combine multiple parameters to customize the output of the shortcode to your liking.

[woof_found_count class="my-custom-class" id="my-custom-id"]

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_found_count] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('woof_found_count', array($this, 'woof_found_count'));

Shortcode PHP function:

function woof_found_count($args = array()) {
            return $this->render_html(WOOF_PATH . 'views/shortcodes/woof_found_count.php', array());
        }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/index.php

Woocommerce Products Filter [woof_ajax_shortcode] Shortcode

The Woocommerce Products Filter shortcode is utilized to dynamically display filtered product results via AJAX. It takes attributes to customize the output.

Shortcode: [woof_ajax_shortcode]

Examples and Usage

Basic example – The following shortcode example showcases how to use the ‘woof_ajax_shortcode’ function to display products filtered by a specific attribute, such as color:

[color_woof color='red' /]

Advanced examples

Here is a more complex shortcode example where the ‘woof_ajax_shortcode’ function is used to filter products by multiple attributes. In this case, the products are being filtered by both color and size:

[color_size_woof color='red' size='large' /]

Another advanced example of the shortcode usage is to filter products by a range of prices. This can be achieved by passing two parameters to the shortcode, representing the minimum and maximum price:

[price_woof min_price='10' max_price='50' /]

These examples demonstrate the versatility of the ‘woof_ajax_shortcode’ function. By passing different parameters to the shortcode, you can filter and display products based on a wide variety of attributes.

PHP Function Code

In case you have difficulties debugging what causing issues with [woof_ajax_shortcode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode(esc_attr($tag) . "_woof", array($this, 'woof_ajax_shortcode'));

Shortcode PHP function:

function woof_ajax_shortcode($atts, $content, $tag) {
            $attr_str = "";
            if (is_array($atts)) {
                foreach ($atts as $key => $val) {
                    if (is_int($key)) {
                        $attr_str .= " " . $val;
                    } else {
                        $attr_str .= sprintf(" %s='%s'", $key, $val);
                    }
                }
            }
            $shortcode = str_replace("_woof", "", $tag);
            ob_start();
            ?>

            <div id="woof_results_by_ajax" class="woof_results_by_ajax_shortcode" data-shortcode="<?php echo esc_attr($tag . $attr_str) ?>" >
                <?php
                echo do_shortcode("[" . esc_html($shortcode . $attr_str) . " ]");
                ?>
            </div>
            <?php
            return ob_get_clean();
        }

Code file location:

woocommerce-products-filter/woocommerce-products-filter/index.php

Conclusion

Now that you’ve learned how to embed the Woocommerce Products Filter Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *