Advanced AJAX Product Filters Shortcodes

Below, you’ll find a detailed guide on how to add the Advanced AJAX Product Filters 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 Advanced AJAX Product Filters Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Advanced AJAX Product Filters Plugin and the shortcodes it provides:

Plugin Icon
Advanced AJAX Product Filters

"Advanced AJAX Product Filters is a dynamic WordPress plugin that enhances your WooCommerce store functionality by adding powerful, easy-to-use AJAX product filters for a superior shopping experience."

★★★★☆ (343) Active Installs: 60000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [br_filter_single]
  • [brapf_next_shortcode_apply]
  • [replace_with_products]

Advanced AJAX Product Filters [br_filter_single] Shortcode

The ‘br_filter_single’ shortcode is part of the WooCommerce Ajax Filters plugin. It initiates a widget that filters single products based on attributes. The PHP function ‘shortcode’ is triggered, which starts output buffering. It then calls the ‘BeRocket_new_AAPF_Widget_single’ widget using the passed attributes. The output is then returned and cleaned.

Shortcode: [br_filter_single]

Examples and Usage

Basic example – The following example demonstrates a simple usage of the ‘br_filter_single’ shortcode. In this case, no additional parameters or attributes are passed, so the shortcode will use its default settings.

[br_filter_single]

PHP Function Code

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

Shortcode line:

add_shortcode( 'br_filter_single', array( $this, 'shortcode' ) );

Shortcode PHP function:

function shortcode($atts = array()) {
        ob_start();
        the_widget( 'BeRocket_new_AAPF_Widget_single', $atts);
        return ob_get_clean();
    }

Code file location:

woocommerce-ajax-filters/woocommerce-ajax-filters/includes/custom_post.php

Advanced AJAX Product Filters [brapf_next_shortcode_apply] Shortcode

The Woocommerce-Ajax-Filters plugin shortcode ‘brapf_next_shortcode_apply’ is designed to apply or remove filters on your WooCommerce store. This shortcode checks if the ‘apply’ attribute is set to true or false. If set to true, it applies the filter to your store. If set to false, it removes the filter. This provides flexibility in managing your store’s filters.

Shortcode: [brapf_next_shortcode_apply]

Parameters

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

  • apply – Determines whether to apply or not apply the filter

Examples and Usage

Basic example – Utilizes the ‘brapf_next_shortcode_apply’ shortcode to apply the filter without any specific parameters.

[brapf_next_shortcode_apply]

Advanced examples

Applies the filter by setting the ‘apply’ attribute to true. When the ‘apply’ attribute is set to true, the ‘add_apply_filter()’ function is triggered.

[brapf_next_shortcode_apply apply=true]

Does not apply the filter by setting the ‘apply’ attribute to false. When the ‘apply’ attribute is set to false, the ‘add_not_apply_filter()’ function is triggered.

[brapf_next_shortcode_apply apply=false]

Leaves the application of the filter to its default setting by setting the ‘apply’ attribute to ‘default’. If the ‘apply’ attribute is set to ‘default’, the filter’s application is left to its default setting.

[brapf_next_shortcode_apply apply=default]

PHP Function Code

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

Shortcode line:

add_shortcode( 'brapf_next_shortcode_apply', array( $this, 'shortcode_apply' ) );

Shortcode PHP function:

function shortcode_apply( $atts = array() ) {
            if( ! is_array($atts) ) $atts = array();
            $atts = array_merge(array('apply' => true), $atts);
            $this->remove_all();
            if( $atts['apply'] === 'false') $atts['apply'] = false;
            if($atts['apply'] !== 'default') {
                $atts['apply'] = (bool) $atts['apply'];
                if( $atts['apply'] ) {
                    $this->add_apply_filter();
                } else {
                    $this->add_not_apply_filter();
                }
            }
        }

Code file location:

woocommerce-ajax-filters/woocommerce-ajax-filters/includes/shortcode_apply_filters.php

Advanced AJAX Product Filters [replace_with_products] Shortcode

The Woocommerce-ajax-filters plugin shortcode is designed to replace content with products. It takes the set parameters, such as pagination and limit, and integrates them into the products shortcode. This shortcode fetches the desired number of products per page and enables pagination if set. It then returns the updated products using the ‘do_shortcode’ function.

Shortcode: [replace_with_products]

Examples and Usage

Basic example – The following shortcode will display a list of products with no limit on the number of products per page and without pagination:

[br_products]

Advanced examples

1. The following shortcode will display a list of products with a limit of 10 products per page. It also enables pagination:

[br_products per_page=10 paginate=1]

2. This shortcode will display a list of products with a limit of 20 products per page without pagination:

[br_products per_page=20]

3. The following shortcode will display a list of products with no limit on the number of products per page but with pagination enabled:

[br_products paginate=1]

Note that in the shortcode, ‘br_products’ is a placeholder for the actual shortcode you will use, ‘per_page’ is the parameter for limiting the number of products per page, and ‘paginate’ is the parameter for enabling pagination.

PHP Function Code

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

Shortcode line:

add_shortcode( $shortcode, array($this, 'replace_with_products') );

Shortcode PHP function:

function replace_with_products($atts = array()) {
        $option = $this->get_option();
        $per_page = empty($option['products_only_shortcode_per_page']) ? '' : intval($option['products_only_shortcode_per_page']);
        $paginate = empty($option['products_only_shortcode_pagiantion']) ? '' : ' paginate="1"';
        $per_page = empty($per_page) ? '' : ' limit="'.$per_page.'"';
        return do_shortcode( '[products berocket_aapf="true"' . $paginate . $per_page . ']' );
    }

Code file location:

woocommerce-ajax-filters/woocommerce-ajax-filters/main.php

Conclusion

Now that you’ve learned how to embed the Advanced AJAX Product Filters 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 *