Free Shipping Over Amount Bar for WooCommerce Shortcodes

Below, you’ll find a detailed guide on how to add the Free Shipping Over Amount Bar for WooCommerce Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Free Shipping Over Amount Bar for WooCommerce Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Free Shipping Over Amount Bar for WooCommerce Plugin and the shortcodes it provides:

Plugin Icon
Free Shipping Over Amount Bar for WooCommerce

"Free Shipping Over Amount Bar for WooCommerce is a plugin that helps boost sales by displaying a dynamic bar showing the amount left to reach free shipping."

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

Free Shipping Over Amount Bar for WooCommerce [alg_get_left_to_free_shipping] Shortcode

The ‘alg_get_left_to_free_shipping’ shortcode of the Amount Left for Free Shipping Woocommerce plugin calculates the remaining amount needed to qualify for free shipping. It uses parameters like ‘content’, ‘template’, ‘multiply_by’, ‘min_free_shipping_amount’, ‘free_delivery_text’, and ‘min_cart_amount’ for customization.

Shortcode: [alg_get_left_to_free_shipping]

Parameters

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

  • content – Custom text that will be displayed.
  • template – The layout of the displayed content.
  • multiply_by – Multiplier for the free shipping amount.
  • min_free_shipping_amount – Minimum amount for free shipping.
  • free_delivery_text – Text to display when free delivery is available.
  • min_cart_amount – The minimum cart value for the free shipping offer.

Examples and Usage

Basic example – A simple usage of the shortcode to display the amount left for free shipping

[alg_get_left_to_free_shipping]

Advanced examples

Using the shortcode with specific parameters to customize the output. This example multiplies the amount left by 2, sets a minimum free shipping amount, and includes a custom message for free delivery.

[alg_get_left_to_free_shipping multiply_by=2 min_free_shipping_amount=50 free_delivery_text="Congratulations! You have qualified for free shipping!"]

Another advanced usage of the shortcode. This example sets a specific minimum cart amount and customizes the template of the output.

[alg_get_left_to_free_shipping min_cart_amount=100 template="You need to add {content} more to your cart for free shipping."]

PHP Function Code

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

Shortcode line:

add_shortcode( 'alg_get_left_to_free_shipping',          array( $this, 'get_left_to_free_shipping_shortcode' ) ); // deprecated

Shortcode PHP function:

                    function get_left_to_free_shipping_shortcode( $atts, $content ) {
		if ( ! alg_wc_left_to_free_shipping_is_admin() ) {
			$atts = shortcode_atts( array(
				'content'                  => '',
				'template'                 => '{content}',
				'multiply_by'              => 1,
				'min_free_shipping_amount' => 0,
				'free_delivery_text'       => false,
				'min_cart_amount'          => get_option( 'alg_wc_left_to_free_shipping_min_cart_amount', 0 )
			), $atts, 'alg_wc_left_to_free_shipping' );
			return $this->get_left_to_free_shipping( $atts );
		} else {
			return '';
		}
	}
                    

Code file location:

amount-left-free-shipping-woocommerce/amount-left-free-shipping-woocommerce/includes/class-alg-wc-alfs-core.php

Free Shipping Over Amount Bar for WooCommerce [alg_wc_left_to_free_shipping_translate] Shortcode

The ‘alg_wc_left_to_free_shipping_translate’ shortcode is used for translating text based on the site’s language. It checks if the ‘lang_text’ and ‘not_lang_text’ attributes are set and if the current language matches the ‘lang’ attribute. If it matches, it returns the ‘lang_text’, otherwise, it returns the ‘not_lang_text’. It also works with enclosing content, returning the content if the current language matches ‘lang’ or doesn’t match ‘not_lang’.

Shortcode: [alg_wc_left_to_free_shipping_translate]

Parameters

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

  • lang – The language code for the translation
  • lang_text – The text to display if the current language matches ‘lang’
  • not_lang_text – The text to display if the current language does not match ‘lang’
  • not_lang – The language code to exclude from the translation

Examples and Usage

Basic example – A shortcode that displays the amount left for free shipping in English.

[alg_wc_left_to_free_shipping_translate lang="EN" lang_text="%amount_left_for_free_shipping% left for free shipping"]

Advanced examples

Display the amount left for free shipping in German if the site language is set to German, otherwise display it in English.

[alg_wc_left_to_free_shipping_translate lang="DE" lang_text="%amount_left_for_free_shipping% für kostenlosen Versand" not_lang_text="%amount_left_for_free_shipping% left for free shipping"]

Using nested shortcodes to display the amount left for free shipping in German or English depending on the site language.

[alg_wc_left_to_free_shipping_translate lang="DE"]%amount_left_for_free_shipping% für kostenlosen Versand[/alg_wc_left_to_free_shipping_translate][alg_wc_left_to_free_shipping_translate not_lang="DE"]%amount_left_for_free_shipping% left for free shipping[/alg_wc_left_to_free_shipping_translate]

PHP Function Code

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

Shortcode line:

add_shortcode( 'alg_wc_left_to_free_shipping_translate', array( $this, 'translate_shortcode' ) );

Shortcode PHP function:

                    function translate_shortcode( $atts, $content = '' ) {
		// E.g.: `[alg_wc_left_to_free_shipping_translate lang="DE" lang_text="%amount_left_for_free_shipping% für kostenlosen Versand" not_lang_text="%amount_left_for_free_shipping% left for free shipping"]`
		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_left_to_free_shipping_translate lang="DE"]%amount_left_for_free_shipping% für kostenlosen Versand[/alg_wc_left_to_free_shipping_translate][alg_wc_left_to_free_shipping_translate not_lang="DE"]%amount_left_for_free_shipping% left for free shipping[/alg_wc_left_to_free_shipping_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:

amount-left-free-shipping-woocommerce/amount-left-free-shipping-woocommerce/includes/class-alg-wc-alfs-core.php

Conclusion

Now that you’ve learned how to embed the Free Shipping Over Amount Bar for WooCommerce Plugin shortcodes, 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 *