Quantcast
Channel: WordPress.org Forums » [WooCommerce] Support
Viewing all articles
Browse latest Browse all 104029

Coen Jacobs on "[Plugin: WooCommerce - excelling eCommerce] Shipping Automatically set?"

$
0
0

So if I get it right, you want to disable the paid option if the free shipping option is available? You can do this by filtering the available shipping methods:

add_filter( 'woocommerce_available_shipping_methods', 'cj_woocommerce_available_shipping_methods' );

function cj_woocommerce_available_shipping_methods( $available_methods ) {
	if ( isset( $available_methods['free_shipping'] ) ) {
		foreach ( $available_methods as $key => $value ) {
			if ( 'free_shipping' != $key ) {
				unset( $available_methods[ $key ] );
			}
		}
	}	

	return $available_methods;
}

This will deactivate all shipping methods, except for free, when free is available. Place this code in a plugin, or in your (child) themes functions.php.


Viewing all articles
Browse latest Browse all 104029

Trending Articles