Cost field used to support text

Home Forums Calendar Products Events Calendar PRO Cost field used to support text

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1002478
    pickleshy
    Participant

    Hi,

    I’ve been running ECP since January 2014 on this site: http://livemusicproject.org/calendar/

    I am currently upgrading the event calendar plugins (Event Calendar, ECP, Community Events) on my staging site, making the large leap from 3.92 to 3.11.2.

    Until now, it has been possible to treat the cost field as a text field, which enabled me to support the following price descriptors:

    • $10-$25
    • $20 ($10 student/senior)
    • $10 (age 12 & under free)

    In my general settings, I did not elect to place a currency symbol before or after the price.

    Looking at the latest updates on my staging site, I see that the cost field is now attempting to turn all price descriptors into a range, stripping out all formatting that is not a number (and at times, stripping out the numbers as well). Thus, all existing cost data is transformed when it does not conform to a narrow standard:

    • $10-$25 –> becomes 10
    • $20 ($10 student/senior) –> becomes 20
    • $10 (age 12 & under free) –> becomes 10

    See testing event here: http://stage-seattle.livemusicproject.org/event/test-event-to-test-dolla-dolla-signs/

    It appears this transformation is occurring upon retrieval/display, and the cost data is, in fact, intact in the database.

    Is there a way to escape this sterilization process and maintain the integrity of my cost data on display, so that the hundreds of existing events on my site remain accurate?

    • This topic was modified 8 years, 7 months ago by pickleshy.
    #1002628
    Nico
    Member

    Hi @pickleshy,

    Thanks for reaching out to us! Hopefully I can help you out on this 🙂

    Check out this snippet Barry provided to other customers having the same issue: https://theeventscalendar.com/support/forums/topic/cost-format/#dl_post-989616

    Please let me know if it does the trick for you,
    Best,
    Nico

    #1002645
    pickleshy
    Participant

    Awesome, I’ll try it! Thanks!

    #1003018
    Nico
    Member

    Great, just let me know about it!

    Best,
    Nico

    #1003119
    pickleshy
    Participant

    Hi Nico,

    For the most part it works great! The one issue we still have is that when the cost of an event is 0, the “Free” label goes away (the entire label is hidden).

    We’re thinking of using the following workaround:

    function verbatim_cost_field( $cost, $post_id ) {
    
        $freeStr = "free";
        $pos = stripos($cost, $freeStr, 0);
        if ($pos !== false)
        {
            return $cost;
        }
    
        return esc_html( get_post_meta( $post_id, '_EventCost', true ) );
    }
    add_filter( 'tribe_get_cost', 'verbatim_cost_field', 10, 2 );

    Does that look about right to you?

    #1003307
    Nico
    Member

    Hey @pickleshy,

    That looks good indeed, thanks for sharing 🙂

    In guess you tested that out and fixes the “0” issue right?

    Best,
    Nico

    #1008255
    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 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Cost field used to support text’ is closed to new replies.