Home › Forums › Calendar Products › Community Events › Community event submit form: Rules when event cost change to "Free entry"
- This topic has 6 replies, 3 voices, and was last updated 7 years, 5 months ago by Cliff.
-
AuthorPosts
-
October 20, 2016 at 10:43 am #1179989OliverParticipant
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 senseWe 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.
October 20, 2016 at 9:36 pm #1180362CliffMemberHi 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.
October 30, 2016 at 10:01 am #1185069October 31, 2016 at 11:22 am #1185381CliffMemberThis reply is private.
November 2, 2016 at 11:24 am #1186491OliverParticipantThanks, that works like a charm! 🙂
Best,
OliverNovember 2, 2016 at 2:54 pm #1186606CliffMemberExcellent! 🙂
-
AuthorPosts
- The topic ‘Community event submit form: Rules when event cost change to "Free entry"’ is closed to new replies.