EU/UK VAT Manager for WooCommerce Shortcode

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

Before starting, here is an overview of the EU/UK VAT Manager for WooCommerce Plugin and the shortcodes it provides:

Plugin Icon
EU/UK VAT Manager for WooCommerce

"EU/UK VAT Manager for WooCommerce is a powerful plugin designed to handle VAT compliance for your WooCommerce store. It seamlessly integrates with your setup, ensuring all transactions comply with EU/UK tax laws."

★★★★★ (21) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [alg_wc_eu_vat_translate]

EU/UK VAT Manager for WooCommerce [alg_wc_eu_vat_translate] Shortcode

The ‘alg_wc_eu_vat_translate’ shortcode from the EU VAT for WooCommerce plugin is designed to handle language translation for VAT-related text based on the user’s language setting. It allows specific text to be displayed depending on whether the user’s language matches the specified languages in the ‘lang’ attribute, or if it doesn’t match the languages in the ‘not_lang’ attribute.

Shortcode: [alg_wc_eu_vat_translate]

Parameters

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

  • lang – Defines the language(s) for the shortcode content.
  • lang_text – Sets the text to display for the specified language(s).
  • not_lang_text – Sets the text to display for languages not specified.
  • not_lang – Defines the language(s) that should not display the shortcode content.

Examples and Usage

Basic example – A simple way to translate “EU VAT Number” into German language using the shortcode.

[alg_wc_eu_vat_translate lang="DE" lang_text="EU-Steuernummer" not_lang_text="EU VAT Number"]

Advanced examples

Displaying “EU VAT Number” in German for German language site and in Dutch for Dutch language site, while displaying the English version for all other languages.

[alg_wc_eu_vat_translate lang="DE"]EU-Steuernummer[/alg_wc_eu_vat_translate][alg_wc_eu_vat_translate lang="NL"]BTW nummer van de EU[/alg_wc_eu_vat_translate][alg_wc_eu_vat_translate not_lang="DE,NL"]EU VAT Number[/alg_wc_eu_vat_translate]

Displaying “EU VAT Number” in German for German language site, while hiding it for Dutch language site and displaying the English version for all other languages.

[alg_wc_eu_vat_translate lang="DE"]EU-Steuernummer[/alg_wc_eu_vat_translate][alg_wc_eu_vat_translate not_lang="DE,NL"]EU VAT Number[/alg_wc_eu_vat_translate]

PHP Function Code

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

Shortcode line:

add_shortcode( 'alg_wc_eu_vat_translate',                                array( $this, 'language_shortcode' ) );

Shortcode PHP function:

                    function language_shortcode( $atts, $content = '' ) {
		// E.g.: `[alg_wc_eu_vat_translate lang="DE,NL" lang_text="EU-Steuernummer" not_lang_text="EU VAT Number"]`
		if ( isset( $atts['lang_text'] ) && isset( $atts['not_lang_text'] ) && ! empty( $atts['lang'] ) ) {
			return ( ! defined( 'ICL_LANGUAGE_CODE' ) || ! in_array( strtolower( ICL_LANGUAGE_CODE ), array_map( 'trim', explode( ',', strtolower( $atts['lang'] ) ) ) ) ) ?
				$atts['not_lang_text'] : $atts['lang_text'];
		}
		// E.g.: `[alg_wc_eu_vat_translate lang="DE"]EU-Steuernummer[/alg_wc_eu_vat_translate][alg_wc_eu_vat_translate lang="NL"]BTW nummer van de EU[/alg_wc_eu_vat_translate][alg_wc_eu_vat_translate not_lang="DE,NL"]EU VAT Number[/alg_wc_eu_vat_translate]`
		return (
			( ! empty( $atts['lang'] )     && ( ! defined( 'ICL_LANGUAGE_CODE' ) || ! in_array( strtolower( ICL_LANGUAGE_CODE ), array_map( 'trim', explode( ',', strtolower( $atts['lang'] ) ) ) ) ) ) ||
			( ! empty( $atts['not_lang'] ) &&     defined( 'ICL_LANGUAGE_CODE' ) &&   in_array( strtolower( ICL_LANGUAGE_CODE ), array_map( 'trim', explode( ',', strtolower( $atts['not_lang'] ) ) ) ) )
		) ? '' : $content;
	}
                    

Code file location:

eu-vat-for-woocommerce/eu-vat-for-woocommerce/includes/class-alg-wc-eu-vat-core.php

Conclusion

Now that you’ve learned how to embed the EU/UK VAT Manager 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 *