Community event submit form: Rules when event cost change to "Free entry"

Home Forums Calendar Products Community Events Community event submit form: Rules when event cost change to "Free entry"

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1179989
    Oliver
    Participant

    Hi,

    some days ago we realized some weird behavior of the event cost field.
    When submitting an event the following strings in the event cost field lead to different results:

    26 (abc) def -> 26
    26 abc -> 26
    26 (abc) -> 26
    26 / -> 26
    19,50 -> 19,50
    19.50 -> 19.50
    26,- -> 26,

    => Fine (more or less…)

    26,- 28,- 30,- (abc) -> Eintritt frei (Free entry)
    26,-/28,-/30,- -> Eintritt frei (Free entry)
    => Doesn’t make sense

    We couldn’t find out how the rule works that changes the text.
    In the docs it states, when “0” (zero) is submitted it will change to “Free entry”.

    For us this is a big issue, because in the last two examples a significant price of the ticket leads to a free ticket, which creates trouble on the organizer side…

    Can you bring light to the dark?

    Best regards,
    Oliver

    • This topic was modified 7 years, 6 months ago by Oliver.
    #1180362
    Cliff
    Member

    Hi Oliver.

    Sorry you’re experiencing this.

    Digging into the code for the “Cost” field under the “Event Cost” section of the Community Events form…

    This “EventCost” field gets ran through quite a few functions, starting with /wp-content/plugins/the-events-calendar-community-events/src/Tribe/Submission_Scrubber.php

    I tested this:

    $tests = array(
    '26 (abc) def',
    '26 abc',
    '26 (abc)',
    '26 /',
    '19,50',
    '19.50',
    '26,-',
    '26,- 28,- 30,- (abc)',
    '26,-/28,-/30,-',
    );
    
    foreach ( $tests as $key => $value ) {
    printf( '%s: %s<br><br>', $key, stripslashes( $value ) );
    }

    (including swapping stripslashes with other functions to test them too)

    Therefore, I’d guess tribe_get_cost() is at play, although I only see it used in /wp-content/plugins/the-events-calendar-community-events/src/views/community/modules/cost.php

    It uses get_formatted_event_cost() from /wp-content/plugins/the-events-calendar/src/Tribe/Cost_Utils.php

    If you search through this file, you’ll see several instances of “preg” and “regex”, which could be the ultimate cause.

    I am somewhat guessing that this is at play too: https://github.com/moderntribe/the-events-calendar/blob/4.3.1.1/src/Tribe/Cost_Utils.php#L225

    Another indicator tribe_get_cost() may be the culprit is because entering the Cost as “26 28 30” in the CE form results in it displaying the Cost as “26 – 30”

    In summary, this isn’t easy to track down and using “Free” as the fallback could definitely backfire in situations like you’ve described.

    If that’s the takeaway here, you could request this as an improvement (or maybe search to see if the idea was already posted by someone else) at our plugins’ UserVoice page.

    This allows others who are interested in that feature to easily voice their support. We frequently review suggestions there to find out which ones are popular, then we implement as many of them as we can.

    If you post it / find it, feel free to link to it from here in case anyone comes across this forum thread in the future.

    Let me know your thoughts on this one.

    #1185069
    Oliver
    Participant

    This reply is private.

    • This reply was modified 7 years, 5 months ago by Oliver.
    #1185381
    Cliff
    Member

    This reply is private.

    #1186491
    Oliver
    Participant

    Thanks, that works like a charm! 🙂

    Best,
    Oliver

    #1186606
    Cliff
    Member

    Excellent! 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Community event submit form: Rules when event cost change to "Free entry"’ is closed to new replies.