Smart Variations Images Shortcode

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

Before starting, here is an overview of the Smart Variations Images Plugin and the shortcodes it provides:

Plugin Icon
Smart Variations Images & Swatches for WooCommerce

"Smart Variations Images & Swatches for WooCommerce is a dynamic plugin that enhances your e-commerce site. It enables the display of different product variations with unique images and swatches, enhancing user experience."

★★★★☆ (132) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 7.4
Included Shortcodes:
  • [svi_wcsc]

Smart Variations Images [svi_wcsc] Shortcode

The Smart Variations Images (SVI) shortcode is used to render images on the frontend of a website. This shortcode calls the function ‘render_sc_frontend’, which buffers the output of the included file ‘smart-variations-images-public-display.php’. The buffered content is then stored in the variable ‘$output_string’, which is returned and displayed on the frontend.

Shortcode: [svi_wcsc]

Examples and Usage

Basic example – A simple representation of the shortcode without any additional parameters. It will invoke the ‘render_sc_frontend’ function and display the content of ‘smart-variations-images-public-display.php’ file.

[svi_wcsc /]

Advanced examples

Displaying smart variation images by referencing the product ID. The images will load according to the product ID provided.

[svi_wcsc id="123" /]

Displaying smart variation images by referencing the product ID and specifying a size. The images will load according to the product ID and size provided.

[svi_wcsc id="123" size="large" /]

Displaying smart variation images by referencing the product ID, specifying a size, and defining the layout. The images will load according to the product ID, size, and layout provided.

[svi_wcsc id="123" size="large" layout="grid" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'svi_wcsc', [ $plugin_public, 'render_sc_frontend' ] );

Shortcode PHP function:

function render_sc_frontend()
    {
        ob_start();
        include plugin_dir_path( dirname( __FILE__ ) ) . 'public/partials/smart-variations-images-public-display.php';
        $output_string = ob_get_contents();
        ob_end_clean();
        return $output_string;
    }

Code file location:

smart-variations-images/smart-variations-images/includes/class-smart-variations-images.php

Conclusion

Now that you’ve learned how to embed the Smart Variations Images 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 *