Add product ID’s to this array and they will automatically quality the cart for free shipping
add_filter( 'woocommerce_shipping_free_shipping_is_available', 'kpry_my_free_shipping', 20 );
function kpry_my_free_shipping( $is_available ) {
global $woocommerce;
// set the product ids that are eligible
$eligible = array(
'29582', // SMOKE IT UP GIFT PACK
'29585', // COOK IT UP GIFT PACK
'29583', // LIGHT IT UP GIFT PACK
'29586' // FLAVOUT IT UP GIFT PACK
);
// get cart contents
$cart_items = $woocommerce->cart->get_cart();
// loop through the items looking for one in the eligible array
foreach ( $cart_items as $key => $item ) {
if( in_array( $item['product_id'], $eligible ) ) {
return true;
}
}
// nothing found return the default value
return $is_available;
}