Last active
July 16, 2020 21:35
-
-
Save maxkostinevich/a5c94f635a7848fcba03767feb3711ab to your computer and use it in GitHub Desktop.
WooCommerce - How to change available package rates depending on cart total
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Change available package rates depending on cart total | |
function shipping_method_on_cart_total( $rates, $package ) { | |
$cart_total = WC()->cart->total; | |
$condition_price = 1000.00; | |
if( $cart_total > $condition_price ) { | |
unset( $rates['free_shipping'] ); // Remove free shipping | |
} | |
return $rates; | |
} | |
add_filter( 'woocommerce_package_rates', 'shipping_method_on_cart_total', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment