View Categories

Free Shipping Bar: Developer Hooks and Filters Reference

This reference lists the PHP hooks, filters, and helper function exposed by the Free Shipping Bar: Amount Left for Free Shipping for WooCommerce. Names are taken directly from the plugin source (version 2.5.4). Add your snippets to a child theme functions.php or a small custom plugin.

Filters #

Filter Passed value Purpose
alg_wc_get_left_to_free_shipping string $result, array $args The final message HTML before it is printed. Modify or wrap the output.
alg_wc_get_left_to_free_shipping_args array $args The argument array (content, location, template, and so on) before the message is built.
alg_wc_get_left_to_free_shipping_validation bool $validation, array $args Return false to hide the message for the current request. This is the hook the Pro category and user-role hiding uses.
alg_wc_left_to_free_shipping_cart_total float $total The cart total the plugin uses in its calculation. Adjust to include or exclude custom amounts.
alg_wc_left_to_free_shipping_manual_min_amount array $data, array $args The resolved manual minimum (amount, is_available). The WooCommerce Currency Switcher conversion hooks in here.
alg_wc_left_to_free_shipping_manual_min_amount_available_types array $id_array, array $args The list of matched extra-option keys (role, currency, zone, method, class) for the current cart.
alg_wc_left_to_free_shipping_amount_types array $types The extra-option types available for manual amounts (roles, currencies, zones, shipping_methods, shipping_classes).
alg_wc_left_to_free_shipping_ajax_events string $events Extra space-separated JavaScript events that trigger an AJAX refresh, added on top of the settings field.
alg_wc_left_to_free_shipping_wide_notice_animation_time int $ms (default 300) Animation duration in milliseconds for the site-wide store notice.

Actions #

Action Passed value Purpose
alg_wc_left_to_free_shipping_core_loaded object $core Fires once the core class is ready. Useful for attaching your own front-end output. Note: this is also used as a filter internally.

Helper function #

Output or retrieve the message anywhere in PHP:

echo alg_wc_get_left_to_free_shipping( array(
    'content'  => '%amount_left_for_free_shipping% left for free shipping',
    'location' => 'custom',
) );

Accepted keys include content, template, multiply_by, min_free_shipping_amount, free_delivery_text, min_cart_amount, and location.

Examples #

Hide the message for a specific page:

add_filter( 'alg_wc_get_left_to_free_shipping_validation', function( $validation, $args ) {
    if ( is_front_page() ) {
        return false;
    }
    return $validation;
}, 10, 2 );

Add a custom refresh event:

add_filter( 'alg_wc_left_to_free_shipping_ajax_events', function( $events ) {
    return trim( $events . ' my_custom_event' );
} );

Shortcodes and widget #

For the registered shortcodes, the widget, and the message placeholders, see the Free shipping shortcodes and widget and Free shipping message placeholders references.

Need a hand? Our team answers every ticket on the Amount Left for Free Shipping support forum.