Woolentor Addons Shortcodes

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

Before starting, here is an overview of the Woolentor Addons Plugin and the shortcodes it provides:

Plugin Icon
ShopLentor – WooCommerce Builder for Elementor & Gutenberg +10 Modules – All in One Solution (formerly WooLentor)

"ShopLentor is a versatile WooCommerce Builder for Elementor & Gutenberg. It includes over 10 modules, offering an all-in-one solution for your eCommerce site. Formerly known as WooLentor, it's the ultimate tool for online shop customization."

★★★★✩ (176) Active Installs: 100000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [woolentorsearch]
  • [evercompare_button]
  • [evercompare_table]
  • [wlpb_trigger_button]
  • [swatchly_pl_swatches]
  • []

Woolentor Addons [woolentorsearch] Shortcode

The Woolentor Search shortcode is a powerful tool for enhancing user experience. It enables an AJAX-powered product search feature within your WordPress site. This shortcode enqueues necessary styles and scripts, then extracts given attributes to customize the search feature. It sets a search limit, placeholder text, and an option to include product categories in the search. The shortcode creates a search form with a unique ID, fields for input, and options for product categories. It also includes loading and clear icons for user interaction. The search results are displayed in a dedicated wrapper.

Shortcode: [woolentorsearch]

Parameters

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

  • limit – Determines the maximum number of search results to display.
  • placeholder – Sets the text that appears in the search box before user input.
  • show_category – If set to ‘1’, a dropdown of product categories will be displayed.
  • all_category_text – Sets the text for the option to search all categories.

Examples and Usage

Basic example – A simple shortcode example that uses the default settings for the Woolentor search plugin. The ‘limit’ attribute is set to 10, and the ‘placeholder’ attribute is set to ‘Search Products’. The ‘show_category’ attribute is set to false, meaning that the category dropdown will not be displayed.

[woolentorsearch /]

Advanced examples

Using the shortcode to display a Woolentor search form with a limit of 5 search results. The placeholder text is set to ‘Find Your Product’, and the ‘show_category’ attribute is set to true, meaning that the category dropdown will be displayed.

[woolentorsearch limit="5" placeholder="Find Your Product" show_category="true" /]

Using the shortcode to display a Woolentor search form with a limit of 20 search results. The placeholder text is set to ‘Search Our Store’, and the ‘show_category’ attribute is set to true. The ‘all_category_text’ attribute is set to ‘All Departments’, which will change the default text for the category dropdown.

[woolentorsearch limit="20" placeholder="Search Our Store" show_category="true" all_category_text="All Departments" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'woolentorsearch', [ $this, 'shortcode' ] );

Shortcode PHP function:

function shortcode( $atts = array(), $content = '' ) {
		
		wp_enqueue_style( 'woolentor-ajax-search' );
        wp_enqueue_script( 'woolentor-ajax-search' );

		extract( shortcode_atts( array(
			'limit' 	  	=> 10,
			'placeholder' 	=> esc_html__( 'Search Products', 'woolentor' ),
			'show_category' => false,
			'all_category_text' => esc_html__('All Categories','woolentor')
		), $atts, 'woolentorsearch' ) );

		$data_settings = array(
			'limit'		  => $limit,
			'wlwidget_id' => '#wluniq-'.uniqid(),
		);

		$category_list = [ '' => $all_category_text ] + woolentor_taxonomy_list( 'product_cat','term_id' );

		$show_category = $show_category == '1' ? true : $show_category;

		$output = '';
		ob_start();
		?>
        	<div class="woolentor_widget_psa" id="wluniq-<?php echo uniqid(); ?>">
	            <form role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" data-settings='<?php echo wp_json_encode( $data_settings ); ?>'>
					<div class="woolentor_widget_psa_field_area">
						<?php if( $show_category === true ):?>
						<div class="woolentor_widget_psa_category">
							<select name="product_cat">
								<?php
									foreach( $category_list as $cat_key => $cat ){
										?>
											<option value="<?php echo esc_attr( $cat_key );?>"><?php echo esc_html( $cat ); ?></option>
										<?php
									}
								?>
							</select>
						</div>
						<?php endif; ?>
						<div class="woolentor_widget_psa_input_field">
							<input type="search" placeholder="<?php echo esc_attr__( $placeholder, 'woolentor' ); ?>" value="<?php echo get_search_query(); ?>" name="s" autocomplete="off" />
							<input type="hidden" name="post_type" value="product" />
							<span class="woolentor_widget_psa_clear_icon"><i class="sli sli-close"></i></span>
							<span class="woolentor_widget_psa_loading_icon"><i class="sli sli-refresh"></i></span>
						</div>
						<button type="submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'woolentor' ); ?>" aria-label="<?php echo esc_attr__( 'Search', 'woolentor' );?>">
							<i class="sli sli-magnifier"></i>
						</button>
					</div>
	                <div id="woolentor_psa_results_wrapper"></div>
	            </form>
	        </div>
		<?php
		$output .= ob_get_clean();
		return apply_filters( 'woolentor_ajaxsearch', $output );
	}

Code file location:

woolentor-addons/woolentor-addons/includes/modules/ajax-search/base.php

Woolentor Addons [evercompare_button] Shortcode

The Woolentor-addons plugin shortcode, ‘evercompare_button’, is designed to generate a comparison button for products on your WordPress site. It fetches button settings from the plugin’s options, such as button text, position, and style. It also retrieves the icons for the button. The shortcode then creates a button with these settings and places it on the product page. It also includes the functionality to change the button text once a product has been added for comparison.

Shortcode: [evercompare_button]

Parameters

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

  • product_id – The unique identifier for the product
  • button_url – The URL where the button will redirect to
  • button_class – The CSS class for the button
  • button_text – The text that appears on the button
  • button_added_text – The text that appears after the product is added
  • template_name – The name of the template to be used for the button

Examples and Usage

Basic example – Display the compare button for a specific product by referencing its product ID.

[evercompare_button product_id=101 /]

Advanced examples

Display the compare button with a custom button URL, and specific button classes. The button will lead to the specified URL when clicked, and the button classes will determine the button’s appearance.

[evercompare_button product_id=101 button_url="http://example.com/compare" button_class="custom-button-class" /]

Display the compare button with custom button text and added button text. The button text will be displayed on the button when the product has not been added to the compare list, and the added button text will be displayed when the product has been added to the compare list.

[evercompare_button product_id=101 button_text="Compare this product" button_added_text="Product added" /]

Display the compare button with a custom template. The template name will determine the layout and style of the compare button.

[evercompare_button product_id=101 template_name="custom-template" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'evercompare_button', [ $this, 'button_shortcode' ] );

Shortcode PHP function:

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

        wp_enqueue_style( 'evercompare-frontend' );
        wp_enqueue_script( 'evercompare-frontend' );

        global $product;

        // Fetch option data
        $button_text        = woolentor_get_option( 'button_text','ever_compare_settings_tabs', 'Compare' );
        $button_added_text  = woolentor_get_option( 'added_button_text','ever_compare_settings_tabs', 'Added' );

        $shop_page_btn_position     = woolentor_get_option( 'shop_btn_position', 'ever_compare_settings_tabs', 'after_cart_btn' );
        $product_page_btn_position  = woolentor_get_option( 'product_btn_position', 'ever_compare_settings_tabs', 'after_cart_btn' );
        $button_style               = woolentor_get_option( 'button_style', 'ever_compare_style_tabs', 'theme' );

        $button_class = array(
            'htcompare-btn',
            'htcompare-btn-style-'.$button_style,
            'htcompare-shop-'.$shop_page_btn_position,
            'htcompare-product-'.$product_page_btn_position,
        );

        if( $button_style === 'theme' ){
            $button_class[] = 'button';
        }

        $button_icon        = $this->get_icon();
        $added_button_icon  = $this->get_icon('added_');
        
        if( !empty( $button_text ) ){
            $button_text = '<span class="evercompare-btn-text">'.$button_text.'</span>';
        }

        if( !empty( $button_added_text ) ){
            $button_added_text = '<span class="evercompare-btn-text">'.$button_added_text.'</span>';
        }

        // Shortcode atts
        $default_atts = array(
            'product_id'        => $product->get_id(),
            'button_url'        => Manage_Compare::instance()->get_compare_page_url(),
            'button_class'      => implode(' ', $button_class ),
            'button_text'       => $button_icon.$button_text,
            'button_added_text' => $added_button_icon.$button_added_text,
            'template_name'     => 'add',
        );

        $atts = shortcode_atts( $default_atts, $atts, $content );
        return Manage_Compare::instance()->button_html( $atts );

    }

Code file location:

woolentor-addons/woolentor-addons/includes/modules/compare/includes/classes/Frontend/Shortcode.php

Woolentor Addons [evercompare_table] Shortcode

The Woolentor-addons plugin shortcode, ‘evercompare_table’, is designed to manage product comparison tables. This shortcode enqueues styles and scripts, fetches options data, retrieves compared products and fields, and sets default attributes. It then merges these attributes with user-defined ones and returns a comparison table.

Shortcode: [evercompare_table]

Examples and Usage

Basic example – A simple use case of the shortcode to generate a comparison table for the product with a specific ID.

[evercompare_table id="1" /]

Advanced examples

Using the shortcode to generate a comparison table for multiple products by specifying their IDs. The table will display the comparison fields for the products with the IDs 1, 2, and 3.

[evercompare_table id="1,2,3" /]

Using the shortcode to generate a comparison table for a product and customizing the return shop button text. The table will display the comparison fields for the product with the ID 1 and the return shop button will have the text “Back to Store”.

[evercompare_table id="1" return_shop_button="Back to Store" /]

Using the shortcode to generate a comparison table for a product and customizing the empty compare text. The table will display the comparison fields for the product with the ID 1 and if no comparison fields are available, the text “No Comparison Available” will be displayed.

[evercompare_table id="1" empty_compare_text="No Comparison Available" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'evercompare_table', [ $this, 'table_shortcode' ] );

Shortcode PHP function:

function table_shortcode( $atts, $content = '' ){
        
        wp_enqueue_style( 'evercompare-frontend' );
        wp_enqueue_script( 'evercompare-frontend' );

        /* Fetch From option data */
        $empty_compare_text = woolentor_get_option('empty_table_text','ever_compare_table_settings_tabs');
        $return_shop_button = woolentor_get_option('shop_button_text','ever_compare_table_settings_tabs','Return to shop');

        /* Product and Field */
        $products   = Manage_Compare::instance()->get_compared_products_data();
        $fields     = Manage_Compare::instance()->get_compare_fields();

        $custom_heading = !empty( woolentor_get_option( 'table_heading', 'ever_compare_table_settings_tabs' ) ) ? woolentor_get_option( 'table_heading', 'ever_compare_table_settings_tabs' ) : array();

        $default_atts = array(
            'evercompare'  => Manage_Compare::instance(),
            'products'     => $products,
            'fields'       => $fields,
            'return_shop_button'=> $return_shop_button,
            'heading_txt'       => $custom_heading,
            'empty_compare_text'=> $empty_compare_text,
        );

        $atts = shortcode_atts( $default_atts, $atts, $content );
        return Manage_Compare::instance()->table_html( $atts );

    }

Code file location:

woolentor-addons/woolentor-addons/includes/modules/compare/includes/classes/Frontend/Shortcode.php

Woolentor Addons [wlpb_trigger_button] Shortcode

The Woolentor ‘wlpb_trigger_button’ shortcode is a versatile tool to customize buttons on your WordPress site. It allows you to define button actions, redirect URLs, button text, button icon, icon position, and button alignment. The shortcode lets you create a button that can either close a popup or redirect to a previous page. It also offers customization options for the button text, icon, and alignment.

Shortcode: [wlpb_trigger_button]

Parameters

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

  • action – determines the action to be taken, either closing the popup or redirecting to a previous page.
  • redirect_url – the URL to which the page will redirect if the ‘go_back_to_previous_page’ action is selected.
  • button_text – the text that will be displayed on the button.
  • button_icon – allows you to add an icon to the button.
  • icon_position – specifies the position of the icon on the button, either left or right.
  • button_align – sets the alignment of the button, it can be centered or aligned to the left or right.

Examples and Usage

Basic example – A simple usage of the wlpb_trigger_button shortcode with the default attributes.

[wlpb_trigger_button /]

Advanced examples

Customizing the wlpb_trigger_button shortcode to change the button text and action, and align the button to the right.

[wlpb_trigger_button button_text="Go Back" action="go_back_to_previous_page" button_align="right" /]

Using the wlpb_trigger_button shortcode to add an icon to the button, position it to the right, and redirect the user to a different URL after clicking the button.

[wlpb_trigger_button button_text="Visit Our Store" button_icon="fas fa-store" icon_position="right" redirect_url="https://www.example.com/store" /]

Using the wlpb_trigger_button shortcode to display a button with a custom HTML icon. The icon will be positioned to the left of the button text.

[wlpb_trigger_button button_text="Read More" button_icon="<i class='fas fa-book-open'></i>" icon_position="left" /]

PHP Function Code

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

Shortcode line:

add_shortcode('wlpb_trigger_button', array($this, 'wlpb_trigger_button_shortcode_cb'));

Shortcode PHP function:

function wlpb_trigger_button_shortcode_cb( $atts ) {
        // Default attribute values.
        $atts = shortcode_atts( array(
            'action'        => 'close_popup', // close_popup, go_back_to_previous_page
            'redirect_url'  => '',
            'button_text'   => __( 'Close', 'woolentor' ),
            'button_icon'   => '',
            'icon_position' => 'left',
            'button_align'  => 'center',
        ), $atts );

        // Sanitize and extract attributes.
        $action        = sanitize_text_field($atts['action']);
        $redirect_url  = esc_url( $atts['redirect_url'] );
        $button_text   = sanitize_text_field($atts['button_text']);
        $button_icon   = $atts['button_icon'];
        $icon_position = sanitize_text_field($atts['icon_position']);
        $button_align  = sanitize_text_field($atts['button_align']);

        // Check if $button_icon is a plain class or an HTML.
        if (strpos($button_icon, '&lt;') !== false) {
            $button_icon = html_entity_decode($button_icon);
        } elseif( $button_icon ) {
            $button_icon = '<i class="' . $button_icon . '"></i>';
        }

        ob_start();
        ?>
        
        <div class="wlpb-trigger-button-wrapper wlpb-trigger-button-align-<?php echo esc_attr($button_align) ?>">
            <span class="wlpb-trigger-button wlpb-trigger-close" data-action="<?php echo esc_attr($action); ?>" data-redirect_url="<?php echo esc_url($redirect_url); ?>">
                <?php if ($icon_position === 'left' && !empty($button_icon)): ?>
                    <?php echo wp_kses_post($button_icon); ?>
                <?php endif; ?>

                <span class="wlpb-trigger-button-text"><?php echo wp_kses_post($button_text); ?></span>

                <?php if ($icon_position === 'right' && !empty($button_icon)): ?>
                    <?php echo wp_kses_post($button_icon); ?>
                <?php endif; ?>
            </span>
        </div><!-- .wlpb-trigger-button-wrapper -->
        

        <?php
        return ob_get_clean();
    }

Code file location:

woolentor-addons/woolentor-addons/includes/modules/popup-builder/includes/class-shortcodes.php

Woolentor Addons [swatchly_pl_swatches] Shortcode

The Woolentor-addons plugin shortcode, ‘swatchly_pl_swatches’, is used to display product variations in a WooCommerce store. The shortcode calls the ‘get_loop_variation_form_html’ function, which checks if the product is variable. If it is, it enqueues the necessary scripts, retrieves product variations, and generates an HTML form. This form displays each variation as a dropdown option, allowing customers to select their preferred product variant. The function also includes options for hiding out-of-stock messages and aligning the form according to the user’s preferences. It’s a powerful tool for enhancing your WooCommerce store’s user experience.

Shortcode: [swatchly_pl_swatches]

Examples and Usage

Basic example – The following shortcode will display the swatches for a variable product by referencing the product ID.

[swatchly_pl_swatches id=123 /]

Advanced examples

Using the shortcode to display the swatches for multiple variable products. The swatches will be displayed for each product referenced by their respective IDs.

[swatchly_pl_swatches id="123,456,789" /]

Using the shortcode to display the swatches for a variable product and hide the out of stock message. The swatches will be displayed for the product referenced by the ID and if the product is out of stock, the out of stock message will be hidden.

[swatchly_pl_swatches id=123 hide_out_of_stock_message=true /]

Using the shortcode to display the swatches for a variable product and align the swatches. The swatches will be displayed for the product referenced by the ID and the alignment of the swatches can be set to left, center, or right.

[swatchly_pl_swatches id=123 align="center" /]

Using the shortcode to display the swatches for a variable product, hide the out of stock message, and align the swatches. The swatches will be displayed for the product referenced by the ID, the out of stock message will be hidden, and the alignment of the swatches can be set to left, center, or right.

[swatchly_pl_swatches id=123 hide_out_of_stock_message=true align="center" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'swatchly_pl_swatches', array( $this, 'get_loop_variation_form_html') );

Shortcode PHP function:

function get_loop_variation_form_html(){
        if( $this->stop_execution() ){
            return;
        }

        global $product;
        if ( ! $product->is_type( 'variable' ) ) {
            return;
        }

        // hide out of stock meesage if the product is not in stock & user opt-in to hide the message
        $hide_out_of_stock_message = apply_filters('swatchly_hide_out_of_stock_message_for_loop_product', false);
        if( !$product->get_available_variations() && $hide_out_of_stock_message ){
            return;
        }

        $align = Helper::get_option('pl_align');

        // Enqueue variation scripts.
        wp_enqueue_script( 'swatchly-add-to-cart-variation' );

        // Get Available variations?
        $get_variations = count( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );
        $available_variations = $get_variations ? $product->get_available_variations() : false;
        $attributes           = $product->get_variation_attributes();
        $selected_attributes  = $product->get_default_attributes();

        $attribute_keys  = array_keys( $attributes );
        $variations_json = wp_json_encode( $available_variations );
        $variations_attr = function_exists( 'wc_esc_json' ) ? wc_esc_json( $variations_json ) : _wp_specialchars( $variations_json, ENT_QUOTES, 'UTF-8', true );

        $html = '';
        ob_start();
        ?>
            <form class="swatchly_loop_variation_form variations_form swatchly_align_<?php echo esc_attr($align); ?>" data-product_variations="<?php echo esc_attr( $variations_json ); ?>" data-product_id="<?php echo absint( $product->get_id() ); ?>" data-product_variations="<?php echo $variations_attr; // WPCS: XSS ok. ?>">

                <?php if ( empty( $available_variations ) && false !== $available_variations ) : ?>
                    <p class="stock out-of-stock"><?php echo esc_html( apply_filters( 'woocommerce_out_of_stock_message', __( 'This product is currently out of stock and unavailable.', 'woolentor' ) ) ); ?></p>
                <?php else : ?>
                    <table class="variations" cellspacing="0">
                        <tbody>
                            <?php foreach ( $attributes as $attribute_name => $options ) : ?>
                                <tr>
                                    <?php if(Helper::get_option('pl_show_swatches_label')): ?>
                                    <td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); // WPCS: XSS ok. ?></label></td>
                                    <?php endif; ?>

                                    <td class="value">
                                        <?php
                                            wc_dropdown_variation_attribute_options(
                                                array(
                                                    'options'   => $options,
                                                    'attribute' => $attribute_name,
                                                    'product'   => $product,
                                                )
                                            );

                                            if(Helper::get_option('pl_show_clear_link')){
                                                echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woolentor' ) . '</a>' ) ) : '';
                                            }
                                        ?>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                <?php endif; ?>
            </form> <!-- .swatchly_loop_variation_form -->
        <?php

        $html = ob_get_clean();
        return $html;
    }

Code file location:

woolentor-addons/woolentor-addons/includes/modules/variation-swatch/includes/Frontend/Woo_Config.php

Conclusion

Now that you’ve learned how to embed the Woolentor Addons 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 *