YITH WooCommerce Ajax Product Filter Shortcode

Below, you’ll find a detailed guide on how to add the YITH WooCommerce Ajax Product Filter Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the YITH WooCommerce Ajax Product Filter Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the YITH WooCommerce Ajax Product Filter Plugin and the shortcodes it provides:

Plugin Icon
YITH WooCommerce Ajax Product Filter

"YITH WooCommerce Ajax Product Filter is a user-friendly WordPress plugin that enhances your e-commerce store's navigation by providing quick and accurate product filters. Stay ahead with smoother shopping experiences."

★★★✩✩ (84) Active Installs: 90000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [add_shortcode]

YITH WooCommerce Ajax Product Filter [add_shortcode] Shortcode

The YITH WooCommerce Ajax Navigation shortcode is designed to render a specific preset filter. It checks if the filter is relevant and then formats the filter type. If the template doesn’t exist, it creates one.

Shortcode: [add_shortcode]

Examples and Usage

Basic example – The following shortcode is used to render the filter with the default preset.

[yith_wcan_filters filter="default" /]

Here, the ‘filter’ attribute refers to the filter to be rendered. The ‘default’ value will use the default preset set in the plugin’s settings.

Advanced examples

Displaying a filter with a custom preset. The preset will override the default settings for the filter.

[yith_wcan_filters filter="custom" preset="my_preset" /]

In this example, ‘filter’ is set to ‘custom’, which means it will use a custom filter. The ‘preset’ attribute is set to ‘my_preset’, which is the name of the preset that will be used to override the default settings.

Adding a filter without a preset. The filter will use the settings defined in the plugin’s settings.

[yith_wcan_filters filter="no_preset" /]

This example shows how to use the shortcode without a preset. The ‘filter’ attribute is set to ‘no_preset’, which means the filter will use the settings defined in the plugin’s settings.

PHP Function Code

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

Shortcode line:

add_shortcode( $tag, array( $classname, 'render' ) );

Shortcode PHP function:

function render() {
			$atts = array(
				'filter' => $this,
				'preset' => $this->get_preset(),
			);

			if ( ! $this->is_relevant() ) {
				return '';
			}

			if ( ! $this->template ) {
				$formatted_type = str_replace( '_', '-', $this->type );
				$this->template = "filter-{$formatted_type}";
			}

			return yith_wcan_get_template( "filters/{$this->template}.php", $atts, false );
		}

Code file location:

yith-woocommerce-ajax-navigation/yith-woocommerce-ajax-navigation/includes/class-yith-wcan-shortcodes.php

Conclusion

Now that you’ve learned how to embed the YITH WooCommerce Ajax Product Filter Plugin shortcode, 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 *