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

Show prices only for logged in users

Added: 1 year ago

Last Updated: 1 year ago

This code ensures that the prices in your store are only displayed for registered and logged in users. Visitors can not see prices.

WooCommerce

AI Verified

0

WooCommerce Disable Payment Gateway Based On Shipping Method

Added: 1 year ago

Last Updated: 1 year ago

If you do not have the facility to take payments other than cash for in-person shipping methods like local pickup, you may wish to disable the appropriate payment gateways and force the customer to pa...

WooCommerce

AI Verified

0

WooCommerce Show Fixed Amount Savings On Sale Products

Added: 1 year ago

Last Updated: 1 year ago

This snippet allows you to display the fixed amount monetary value the customer is saving when a product is on sale.

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

Performance

AI Verified

31

Remove Unused Javascript

Added: 1 year ago

Last Updated: 2 weeks ago

Remove Unused Javascript - and improve your Page Speed Insight Score

WooCommerce

Pro Verified

9

Deactivate some WooCommerce Checkout Fields

Added: 1 year ago

Last Updated: 7 months ago

Deactivate some WooCommerce Checkout Fields from showing

Elementor

AI Verified

6

CSS Grid Aid

Added: 7 months ago

Last Updated: 3 weeks ago

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