Quick View for WooCommerce Shortcode

Below, you’ll find a detailed guide on how to add the Quick View for WooCommerce 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 Quick View for WooCommerce Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Quick View for WooCommerce Plugin and the shortcodes it provides:

Plugin Icon
Quick View for WooCommerce

"Quick View for WooCommerce is an efficient plugin that enhances your online store's user experience. It allows customers to preview products without navigating away from the current page. Simplify shopping with woo-quickview."

★★★★☆ (24) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [woo_quick_view]

Quick View for WooCommerce [woo_quick_view] Shortcode

The ‘woo_quick_view’ shortcode from Woo-QuickView plugin enables a quick view button for WooCommerce products. It fetches the product ID and displays a pop-up view of the product. The shortcode checks the WooCommerce version and gets the product ID accordingly. It also fetches options for the close button and button text from the plugin settings. If a valid product ID exists, it generates and returns the quick view button HTML.

Shortcode: [woo_quick_view]

Parameters

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

  • id – The unique identifier of the WooCommerce product.

Examples and Usage

Basic example – A simple usage of the ‘woo_quick_view’ shortcode with an explicit product ID.

[woo_quick_view id=123 /]

Advanced examples

Using the shortcode without any parameters. In this case, the shortcode will attempt to get the ID of the global product object. This is useful when you want to add the quick view button in a product loop.

[woo_quick_view /]

Using the shortcode with a non-existing product ID. In this case, the shortcode will not render anything because the product with the specified ID does not exist.

[woo_quick_view id=999999 /]

Please note that the actual output of the shortcode may vary depending on your theme and WooCommerce settings. The ‘woo_quick_view’ shortcode is highly flexible and can be used in various ways to enhance the shopping experience on your WooCommerce store.

PHP Function Code

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

Shortcode line:

add_shortcode( 'woo_quick_view', array( $this, 'wqv_shortcode' ) );

Shortcode PHP function:

                    function wqv_shortcode( $atts ) {
		$atts = shortcode_atts(
			array(
				'id' => null,
			),
			$atts,
			'woo_quick_view'
		);

		if ( ! $atts['id'] ) {
			global $woocommerce, $product;
			if ( $woocommerce->version >= '3.0' ) {
				$atts['id'] = $product->get_id();
			} else {
				$atts['id'] = $product->id;
			}
		}

		$close_button           = sp_wqv_get_option( 'wqvpro_popup_close_button' );
		$quick_view_button_text = sp_wqv_get_option( 'wqvpro_quick_view_button_text' );

		$outline = '';
		if ( $atts['id'] ) {
			$outline .= '<a href="#" id="sp-wqv-view-button" class="button sp-wqv-view-button" data-id="' . esc_attr( $atts['id'] ) . '" data-effect="' . sp_wqv_get_option( 'wqvpro_popup_effect' ) . '" data-wqv=\'{"close_button": "' . $close_button . '" } \'>' . $quick_view_button_text . '</a>';
		}
		return $outline;
	}
                    

Code file location:

woo-quickview/woo-quickview/public/views/shortcode.php

Conclusion

Now that you’ve learned how to embed the Quick View for WooCommerce 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 *