Last active
November 6, 2017 08:34
-
-
Save cubehrends/9f23e15fb84a1230cdeea83e15030711 to your computer and use it in GitHub Desktop.
WooCommerce Exclude Free Shipping
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 | |
function free_shipping_based_on_cart_shipping_class( $is_available ) { | |
$cart_items = WC()->cart->get_cart(); | |
foreach ( $cart_items as $cart_item ) { | |
$product = $cart_item['data']; | |
$class = $product->get_shipping_class(); | |
// start slugs of shipping classes excluded from free shipping with 'bulk' | |
if ( substr($class, 0, 4) === 'bulk' ) { | |
return false; | |
} | |
} | |
return $is_available; | |
} | |
add_filter( 'woocommerce_shipping_free_shipping_is_available', 'free_shipping_based_on_cart_shipping_class' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment