Woocommerce Multilingual Shortcode

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

Before starting, here is an overview of the Woocommerce Multilingual Plugin and the shortcodes it provides:

Plugin Icon
WooCommerce Multilingual & Multicurrency with WPML

"WooCommerce Multilingual & Multicurrency with WPML is an incredible plugin that enables your WooCommerce store to support multiple languages and currencies, enhancing global customer experience."

★★★★✩ (299) Active Installs: 100000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [currency_switcher]

Woocommerce Multilingual [currency_switcher] Shortcode

The WooCommerce Multilingual plugin shortcode, ‘currency_switcher’, enables dynamic currency switching on your site. This shortcode captures the output of the ‘wcml_currency_switcher’ function into a string. It then returns this string, allowing the currency switcher to be embedded anywhere on your site.

Shortcode: [currency_switcher]

Examples and Usage

Basic example – The shortcode displays the currency switcher without any additional parameters.

[currency_switcher /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'currency_switcher', [ $this, 'currency_switcher_shortcode' ] );

Shortcode PHP function:

function currency_switcher_shortcode( $atts ) {

		$atts = (array) $atts;

		ob_start();
		$this->wcml_currency_switcher( $atts );
		$html = ob_get_contents();
		ob_end_clean();

		return $html;
	}

Code file location:

woocommerce-multilingual/woocommerce-multilingual/inc/currencies/currency-switcher/class-wcml-currency-switcher.php

Conclusion

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