Created
March 21, 2022 17:58
-
-
Save bporcelli/50d321ed12026d1adf8096fdc09ed67c to your computer and use it in GitHub Desktop.
[MarketShip] Forcibly disable shipping methods.
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 | |
/** | |
* Filters the MarketShip settings to forcibly disable some shipping methods. | |
* | |
* @param array $settings MarketShip settings. | |
* | |
* @return array | |
*/ | |
function marketship_force_disable_shipping_methods( $settings ) { | |
// List shipping methods to disable here. | |
$disabled_methods = array( | |
'shippo', | |
); | |
if ( isset( $settings['enabled_shipping_methods' ] ) ) { | |
$settings['enabled_shipping_methods'] = array_values( | |
array_diff( | |
$settings['enabled_shipping_methods'], | |
$disabled_methods | |
) | |
); | |
} | |
return $settings; | |
} | |
add_filter( 'option_woocommerce_marketship_settings', 'marketship_force_disable_shipping_methods' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment