YITH WooCommerce Quick View Shortcode

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

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

Plugin Icon
YITH WooCommerce Quick View

"YITH WooCommerce Quick View is a user-friendly plugin that enhances your e-commerce site's functionality. It allows customers to preview product details swiftly without navigating away from their current page."

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

YITH WooCommerce Quick View [yith_quick_view] Shortcode

The yith-woocommerce-quick-view shortcode allows you to add a quick view button for a specific product in your WooCommerce store. This shortcode takes two parameters, ‘product_id’ and ‘label’. ‘Product_id’ is the ID of the product you want to display the quick view button for, and ‘label’ is the text that will be displayed on the button.

Shortcode: [yith_quick_view]

Parameters

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

  • product_id – Specifies the unique identifier of the product
  • label – Sets the text displayed on the quick view button

Examples and Usage

Basic example – Show a quick view button for a specific product using its ID.

[yith_quick_view product_id=25 /]

By using the ‘product_id’ attribute, you can specify the product for which the quick view button should be displayed. In this case, the product with the ID 25 will have a quick view button.

Advanced examples

Display a quick view button for a product with a custom label.

[yith_quick_view product_id=25 label="Quick View" /]

In this example, we’re not only specifying the product ID, but we’re also setting a custom label for the quick view button. Instead of the default label, the button will display ‘Quick View’.

Display a quick view button for a product without specifying the product ID.

[yith_quick_view label="Quick View" /]

This example demonstrates the usage of the ‘label’ attribute without defining a specific ‘product_id’. In this case, the quick view button will be displayed for all products with the label ‘Quick View’.

PHP Function Code

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

Shortcode line:

add_shortcode( 'yith_quick_view', array( $this, 'quick_view_shortcode' ) );

Shortcode PHP function:

function quick_view_shortcode( $atts ) {

			$atts = shortcode_atts(
				array(
					'product_id' => 0,
					'label'      => '',
				),
				$atts
			);

			extract( $atts ); // phpcs:ignore

			return $this->yith_add_quick_view_button( intval( $product_id ), $label, true );
		}

Code file location:

yith-woocommerce-quick-view/yith-woocommerce-quick-view/includes/class.yith-wcqv-frontend.php

Conclusion

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