Flexible Shipping – Advanced options and customization

Displaying zero cost for free shipping

If you want to display the shipping methods’ zero cost ($0.00) once the free shipping was triggered, despite the fact that WooCommerce is hiding it automatically, please use the following snippet:

add_filter( 'woocommerce_cart_shipping_method_full_label', 'fs_woocommerce_cart_shipping_method_full_label', 10, 2 ); function fs_woocommerce_cart_shipping_method_full_label( $label, $method ) { $label = $method->get_label(); if ( WC()->cart->display_prices_including_tax() ) { $label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() ); if ( $method->get_shipping_tax() > 0 && ! wc_prices_include_tax() ) { $label .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>'; } } else { $label .= ': ' . wc_price( $method->cost ); if ( $method->get_shipping_tax() > 0 && wc_prices_include_tax() ) { $label .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>'; } } return $label; }

It will result in displaying the zero cost for free shipping the way below:

‘Left to free shipping’ notice customization

Information about the missing amount for free shipping can be easily edited. Just use one of the specially prepared filters:

flexible_shipping_free_shipping_notice_text_message to edit the notice text, flexible_shipping_free_shipping_notice_text_button_label to edit the button label.

Here are some examples of how to use it:

Change the notice text

add_filter( 'flexible_shipping_free_shipping_notice_text_message', function ( $message, $amount ) { return sprintf( 'You only need %1$s more to get free shipping!', $amount ) }, 10, 2 );

All you have to do is replacing the default You only need %1$s more to get free shipping! code fragment with your own text, containing the %1$s section (responsible for displaying the corresponding amount) . After customizing the code according to your needs, just paste it into the functions.php file of the theme/child-theme you are currently using.

Change the button label

add_filter( 'flexible_shipping_free_shipping_notice_text_button_label', function () { return 'Button Label'; } );

Just change the Button Label into your own text. After changing the code, just paste it into the functions.php file.

Delete the button

add_filter( 'flexible_shipping_free_shipping_notice_text_button_label', '__return_empty_string' );

To delete the button from the notice, just paste it into the functions.php file.

Free shipping always on or always off

flexible_shipping_is_free_shipping – a filter which allows the free shipping to be always on or always off for the shipping methods handled by Flexible Shipping.

If you want to set the shipping in your shop to be always free for Flexible Shipping shipping methods whether the free shipping threshold was reached or not, please add the following code to the functions.php file of your theme / child theme or use e.g. the Code Snippets plugin:

add_filter( 'flexible_shipping_is_free_shipping', '__return_true' );

However, if you want the shipping for Flexible Shipping methods in your shop to never be free despite the fact that the free shipping threshold was reached, please use the following code instead:

add_filter( 'flexible_shipping_is_free_shipping', '__return_false' );

Adding a custom field to the FS shipping method

Some of the 3rd party plugins may use the additional fields added directly to the shipping methods. In order to add such custom fields to the shipping method handled by Flexible Shipping plugin you can use the woocommerce_shipping_instance_form_fields_flexible_shipping_single filter.

Usage example:

add_filter( 'woocommerce_shipping_instance_form_fields_flexible_shipping_single', function ( $fields ) { $fields['test'] = [ 'title' => 'Custom field sample title', 'type' => 'text', 'default'=>'test', ]; return $fields; } );

Scroll to Top