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:
"WooCommerce Multilingual & Multicurrency with WPML is an incredible plugin that enables your WooCommerce store to support multiple languages and currencies, enhancing global customer experience."
- [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.
Leave a Reply