Product Gallery Slider for WooCommerce Shortcode

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

Before starting, here is an overview of the Product Gallery Slider for WooCommerce Plugin and the shortcodes it provides:

Plugin Icon
Product Gallery Slider for WooCommerce

"Product Gallery Slider for WooCommerce is a dynamic plugin that enhances your online store by adding a stunning slider to your product galleries. It makes product display visually appealing, leading to increased customer interest and sales."

★★★★✩ (103) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 7.4
Included Shortcodes:
  • [product_gallery_slider]

Product Gallery Slider for WooCommerce [product_gallery_slider] Shortcode

The Woo-Product-Gallery-Slider plugin shortcode is designed to render a product image gallery. It checks if the current page is a product page. If true, it retrieves and displays the product’s image gallery. The output is then cleaned and returned, ensuring smooth operation.

Shortcode: [product_gallery_slider]

Examples and Usage

Basic Example – The below example demonstrates a basic usage of the ‘product_gallery_slider’ shortcode without any additional parameters. This will render the product gallery slider for the current product being viewed.

[product_gallery_slider /]

Advanced Examples

While the given PHP code does not allow for additional parameters, we can imagine a situation where the ‘product_gallery_slider’ shortcode could accept parameters for customizing the output. Here are a couple of examples:

1. Displaying a product gallery slider by product ID:

In this example, we are using the ‘id’ parameter to specify the ID of the product for which we want to display the gallery slider. This could be useful if you want to display the gallery slider for a specific product, rather than the current product being viewed.

[product_gallery_slider id=123 /]

2. Customizing the size of the images in the product gallery slider:

In this example, we are using the ‘image_size’ parameter to specify the size of the images in the gallery slider. This could be useful if you want to customize the appearance of the gallery slider.

[product_gallery_slider image_size="medium" /]

Please note that these are hypothetical examples and would require additional PHP code to handle these parameters.

PHP Function Code

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

Shortcode line:

add_shortcode( 'product_gallery_slider', [$this, 'shortcode_render'] );

Shortcode PHP function:

function shortcode_render() {
		ob_start();
		if ( is_product() ) {
			wc_get_template( 'single-product/product-image.php' );
		}

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

Code file location:

woo-product-gallery-slider/woo-product-gallery-slider/src/Product.php

Conclusion

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