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:

Free shipping zero cost displayed

'Left to free shipping' notice customization

You can use the flexible_shipping_free_shipping_notice_text filter to customize the notice displayed in the cart and on the checkout page informing about the amount of price left to free shipping. Here is the usage example:

add_filter( 'flexible_shipping_free_shipping_notice_text', 'wpdesk_flexible_shipping_free_shipping_notice_text', 10, 2 ); function wpdesk_flexible_shipping_free_shipping_notice_text( $notice_text, $amount ) { return sprintf( 'Changed text: You only need %1$s more to get free shipping! %2$sContinue shopping%3$s', wc_price( $amount ), '<a class="button" target="_blank" href="' . esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ) . '">', '</a>' ); }

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; } );

Flexible Shipping custom field

Still need help? Contact Us Contact Us