Created
March 29, 2021 04:30
-
-
Save WillBrubaker/a612a91aaf83e42c16b97275d26cc09a to your computer and use it in GitHub Desktop.
Conditionally hide shipping methods if payment request button is used for payment
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
// not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/ | |
// BTC Donations to: bc1qc2s60yct2aqza4r7ryweheepd8xa8wqpfgdhg3 | |
//hook into wc_ajax_wc_stripe_get_shipping_options | |
add_action( 'wc_ajax_wc_stripe_get_shipping_options', 'handsome_bearded_guy_filter_shipping_methods' ); | |
function handsome_bearded_guy_filter_shipping_methods() { | |
//hook into woocommerce_shipping_methods | |
add_filter( 'woocommerce_shipping_methods', 'handsome_bearded_guy_remove_shipping_methods' ); | |
} | |
function handsome_bearded_guy_remove_shipping_methods( $shipping_methods ) { | |
unset( $shipping_methods['free_shipping'] );//remove Free Shipping | |
return $shipping_methods; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work with WooCommerce 7.7.0 & WC Stripe 7.4.0
Adding a priority lower than 10 to the
add_action
line allows to reintegrate in the Stripe flowadd_action( 'wc_ajax_wc_stripe_get_shipping_options', 'handsome_bearded_guy_filter_shipping_methods', 1 );