Skip to content

Instantly share code, notes, and snippets.

@softiconic
Last active December 2, 2023 19:01
Show Gist options
  • Save softiconic/fb23ea87432d65a01f9157c04b5d5920 to your computer and use it in GitHub Desktop.
Save softiconic/fb23ea87432d65a01f9157c04b5d5920 to your computer and use it in GitHub Desktop.
Exclude a shipping method on the WooCommerce cart page.
/**
* 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 );
@koengie
Copy link

koengie commented Oct 11, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment