Pro Verified

Name

Adjust betwee Shipping Types based on the WooCommerce Cost Total

About

When the cost is > $100 then Free Shipping applies. Less than that has Flat Rate. The numbers are based on the order in the Woo > Settings > Shipping Page

Language

PHP

Rating

Voted: 1 by 3 user(s)

How to Setup Snippet

Add to Code Snippets

Codevault

WebSquadron

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that 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:

26/07/2023

Important Note

This snippet has the following status:

Pro Verified

This snippet has been verified by a Code Snippet Pro team member.

Pro Comments:

Adjust betwee Shipping Types based on the WooCommerce Cost Total

 
                    
1add_filter( 'woocommerce_package_rates', 'gncy_woocommerce_tiered_shipping', 10, 2 );
2function gncy_woocommerce_tiered_shipping( $rates, $package ) {
3 $threshold1 = 100; // above $100 we have free shipping
4 
5 // If cart subtotal is less than $100, unset/remove free_shipping:1.
6 if ( WC()->cart->subtotal < $threshold1 ) {
7 unset( $rates['free_shipping:2'] );
8 // else cart subtotal is $100 or more, unset/remove flat rate.
9 } else {
10 unset( $rates['flat_rate:1'] );
11 }
12 return $rates;
13}

1

Featured Snippet

Related Snippets

Please see some snippets below related to this snippet..

WooCommerce

AI Verified

0

Change default customer role

Added: 1 year ago

Last Updated: 1 year ago

Assign a custom role to every new WooCommerce customer (use with care!)

WooCommerce

AI Verified

0

Show percent savings on sale

Added: 1 year ago

Last Updated: 1 year ago

You work a lot with offer prices? Then show your visitors how much they have saved compared to the original price.

WooCommerce

AI Verified

1

WooCommerce Show Sale Price Dates On Product Page

Added: 1 year ago

Last Updated: 2 weeks ago

This snippet allows you to show the date range a product is on sale if you had set a sale price in the editor.

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

Performance

AI Verified

33

Remove Unused Javascript

Added: 1 year ago

Last Updated: 4 hours ago

Remove Unused Javascript - and improve your Page Speed Insight Score

WooCommerce

Pro Verified

10

Deactivate some WooCommerce Checkout Fields

Added: 1 year ago

Last Updated: 3 weeks ago

Deactivate some WooCommerce Checkout Fields from showing

Elementor

AI Verified

6

CSS Grid Aid

Added: 8 months ago

Last Updated: 2 months ago

This can be used for any WordPress Builder to aid working with CSS Grids.