Display specific shipping method if woocommerce product has specific acf field value
PHP Snippet 1:
<?php
add_filter( 'woocommerce_package_rates', 'define_default_shipping_method', 10, 2 );
function define_default_shipping_method( $rates, $package ) {
$shipping_id = 'table_rate_shipping_first-class';
$colors = get_field('name_of_your_feild');
if( $colors && in_array('cp', $colors) ) {
unset( $rates[$shipping_id ] ); // you need to unset here other shipping methods
}
return $rates;
}
?>