stuart-d
6/14/2018 - 10:26 AM

Remove free shipping in WooCommerce if a coupon is applied at checkout

Remove free shipping in WooCommerce if a coupon is applied at checkout

add_filter( 'woocommerce_shipping_packages', function( $packages ) {
	$applied_coupons = WC()->session->get( 'applied_coupons', array() );
	if ( ! empty( $applied_coupons ) ) {
		$free_shipping_id = 'free_shipping:2';
		unset($packages[0]['rates'][ $free_shipping_id ]);
	}
	return $packages;
} );