Add same Text to all cost prices in event title on single events page

Home Forums Calendar Products Events Calendar PRO Add same Text to all cost prices in event title on single events page

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1538700
    ftww
    Participant

    Hi There,
    I would like to add the text “Price:” before the amount shown for ticket price in the event details subheading heading on a single events page.

    As per this thread – https://theeventscalendar.com/support/forums/topic/add-text-to-cost-field/
    Jennifer who replied mentioned 2 ways to do this and I would appreciate being pointed in the right direction of where to add the code and text for this.
    Thanks in advance

    #1539824
    Jennifer
    Keymaster

    Hello,

    Thanks for reaching out!

    You can use a modified version of the snippet that I linked to in that post to accomplish this, something like:

    function tribe_price_text_cost_field( $cost, $post_id ) {
    $event_price = esc_html( get_post_meta( $post_id, '_EventCost', true ) );
    if ( tribe_is_event() && is_single() && $event_price > 0 ) {
    return "Price: " . $cost;
    } else {
    return $cost;
    }
    }
    add_filter( 'tribe_get_cost', 'tribe_price_text_cost_field', 10, 2 );

    You’ll want to add that to the functions.php file of your child theme. Please note that we are limited in the amount of support that we can provide for customizations, but we do try to point users in the right direction when we have the bandwidth to do so 🙂

    Let me know if you have any questions!

    Thanks,

    Jennifer

    #1540606
    ftww
    Participant

    Hi Jennifer,
    That worked great and thanks for your assistance. the only thing is that it also adds it in the details block below the events also where there is already a header. I do understand that this is getting in to the area of customisations – on the other hand, I’d argue that having cost: or price: included in the description would look a lot better overall as a customisation!!!.
    So if there is a way for it to only appear in the title that is straightforward that would be really great!
    Thank you

    #1541158
    Jennifer
    Keymaster

    Hello,

    Thanks for the feedback! You can instead do a template customization – our themer’s guide has instructions on doing this, and the template you’ll want to edit can be found at wp-content/plugins/the-events-calendar/src/views/single-event.php. Look for this line:

    <span class="tribe-events-cost"><?php echo tribe_get_cost( null, true ) ?></span>

    You can add the text in like this:

    <span class="tribe-events-cost"><?php echo "Price: " . tribe_get_cost( null, true ) ?></span>

    This will only add it to the price at the top of the page. I hope this helps!

    #1542653
    ftww
    Participant

    Super – thanks – worked a charm!

    #1543256
    Jennifer
    Keymaster

    Perfect! I’m glad this worked for you. I’ll go ahead and close out this thread since it’s been marked “Resolved”, but please feel free to open up a new one if you have any other questions!

    #1559336
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Add same Text to all cost prices in event title on single events page’ is closed to new replies.