Last active
December 2, 2023 19:01
-
-
Save softiconic/fb23ea87432d65a01f9157c04b5d5920 to your computer and use it in GitHub Desktop.
Exclude a shipping method on the WooCommerce cart page.
This file contains hidden or 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
/** | |
* remove shipping method - Cart page | |
* Put this in your functions.php file | |
*/ | |
function disable_shipping_calc_on_cart( $show_shipping ) { | |
if( is_cart() ) { | |
return false; | |
} | |
return $show_shipping; | |
} | |
add_filter( 'woocommerce_cart_ready_to_calc_shipping', 'disable_shipping_calc_on_cart', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used this code:
add_filter( 'woocommerce_cart_ready_to_calc_shipping', 'disable_shipping_calc_on_cart', 99 ); add_filter( 'woocommerce_cart_ready_to_calc_shipping', 'disable_shipping_calc_on_checkout', 99 );
It works great on PHP7 but when I change it to PHP8, I get an error!
I don't understand why and how it has an impact on the PHP version?