Help with callback using do_action_ref_array

That feature exists because I bugged them to implement it 🙂

Using it confused me as well but somebody finally replied to this just the other day with this snippet:

add_action( 'bookly_validate_custom_field', function ( \stdClass $field, &$errors, $cart_key, \stdClass $field_info ) {
    // Validation by custom_field id
    switch ( $field->id ) {
        case 'id_value':
            if ( /*$invalid == */ true ) {
                $errors['custom_fields'][ $cart_key ][ $field->id ] = __( 'Invalid', 'bookly' );
            }
            break;
    }
}, 10, 4 );

Leave a Comment