Event cost field as number field instead of text?

Home Forums Calendar Products Events Calendar PRO Event cost field as number field instead of text?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1023150
    hippies
    Participant

    We’re recurrently having problems with clients adding letters to the event price field (#EventCost) and therefore it displays as “Free” in the frontend.

    Is there any possibility the field type for event cost could be changed from text to number in future updates?

    #1023444
    Nico
    Member

    Howdy @hippies,

    Welcome to our support forums and thanks for reaching out to us. Hopefully I can help you modifying this behavior 🙂

    You’ll need to add the following snippet to the site’s functions.php file (located at wp-content/themes/your_theme/functions.php):

    add_filter( 'tribe_get_cost', 'cost_show_full_meta_field', 10, 2 );

    function cost_show_full_meta_field( $cost, $post_id ) {
    $full_cost = tribe_get_event_meta( $post_id, '_EventCost', false );

    if ( isset( $full_cost[0] ) ) {
    return sanitize_text_field( $full_cost[0] );
    }

    return $cost;
    }

    With this snippet in place you should be able to input strings in the cost field,
    Best,
    Nico

    #1075500
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Event cost field as number field instead of text?’ is closed to new replies.