I found the Make Order notes required if shipping method is local pickup in Woocommerce by LoicTheAztec which makes order notes required and displays a message when a shipping metod is selected. How can I make it search the method name instead of a method type?
I have used this for changing a custom status, can it be used here?
if ( strpos($shipping_method, 'Annan överenskommelse') !== false )
// Validate mandatory "Order notes" field for "Local Pickup" shipping methods
add_action( 'woocommerce_checkout_process', 'local_pickup_order_comment_validation', 20 );
function local_pickup_order_comment_validation() {
$chosen_shipping = WC()->session->get( 'chosen_shipping_methods' )[0];
$chosen_shipping = explode(':', $chosen_shipping);
if ( $chosen_shipping[0] == 'local_pickup' && empty($_POST['order_comments']) ){
wc_add_notice( __( "You need to fill up \"Order notes\" with some details.", "woocommerce" ), 'error' );
}
}