AI Verified

Name

Hide shipping rates when free shipping is available.

About

Why should shipping costs be displayed when free shipping is available for a product? This WooCommerce snippet hides the shipping costs.

Language

PHP

Rating

Voted: 0 by 0 user(s)

Codevault

jbeer

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: Not Specified

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

14/11/2022

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Hide shipping rates when free shipping is available.

 
                    
1if ( !function_exists( 'evolution_hide_shipping_when_free_is_available' ) ) :
2/**
3 * Hide shipping rates when free shipping is available.
4 * Updated to support WooCommerce 2.6 Shipping Zones.
5 *
6 * @param array $rates Array of rates found for the package.
7 * @return array
8 */
9 function evolution_hide_shipping_when_free_is_available( $rates ) {
10 $free = array();
11 foreach ( $rates as $rate_id => $rate ) {
12 if ( 'free_shipping' === $rate->method_id ) {
13 $free[ $rate_id ] = $rate;
14 break;
15 }
16 }
17 return ! empty( $free ) ? $free : $rates;
18 }
19add_filter( 'woocommerce_package_rates', 'evolution_hide_shipping_when_free_is_available', 100 );
20endif;

0

Related Snippets

Please see some snippets below related to this snippet..

WooCommerce

AI Verified

1

WooCommerce Show Custom Text Below Login Form

Added: 1 year ago

Last Updated: 2 months ago

This quick guide shows you how you can add custom content below the login form on the My Account page.

WooCommerce

AI Verified

1

WooCommerce Remove Address 2 Checkout Field

Added: 1 year ago

Last Updated: 2 months ago

WooCommerce

AI Verified

0

WooCommerce Change Add To Cart Button Text On Click

Added: 1 year ago

Last Updated: 1 year ago

A key part of a good User Experience (UX) is feedback. Knowing you’ve clicked on something prevents rage clicks. Have you ever spam clicked the add to cart button because you weren’t sure if a product...

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WooCommerce

AI Verified

3

Confirm Password Field in Woocommerce

Added: 2 years ago

Last Updated: 2 months ago

WooCommerce

AI Verified

3

Redirect customers to own thank-you page after order

Added: 2 years ago

Last Updated: 2 months ago

You may want to redirect your customers to a custom thank you page after they place an order. You can do that with the following WooCommerce snippet

WooCommerce

AI Verified

2

Bypass logout confirmation.

Added: 2 years ago

Last Updated: 3 months ago