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

WooCommerce Add Stock Quantity Prefix

Added: 1 year ago

Last Updated: 1 year ago

This snippet allows you to add any custom prefix to the stock quantity shown on the single product template. In this particular example, we’ve added “Relax…there are” as the prefix....

WooCommerce

AI Verified

0

No Order Status on My Account Order Page

Added: 1 year ago

Last Updated: 1 year ago

WooCommerce

AI Verified

0

Woo Dodaj nesto iza cene

Added: 1 year ago

Last Updated: 1 year ago

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: 2 days 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.