Skip to content

Instantly share code, notes, and snippets.

@cubehrends cubehrends/functions.php
Last active Nov 6, 2017

What would you like to do?
WooCommerce Exclude Free Shipping
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
You can’t perform that action at this time.