Cost range

  • This topic has 7 replies, 2 voices, and was last updated 6 years ago by Robert.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1506175
    Robert
    Participant

    Hello,

    I have Events Calendar Pro and Events Ticket Plus and I create early bird tickets that are only available until a certain date before going away and showing the full ticket price. The issue however is that a range shows at the top of the event and in the meta box at the bottom of the single event and people ask why there is a lower price available but they’re unable to select it. Is there a way to modify this so that it only shows the price at the given time and no range? So if early bird tickets just show that price, and same with regular tickets?

    I see that the cost is tied to this function: tribe_get_formatted_cost() but not sure how to modify it. Thanks.

    #1507140
    Victor
    Keymaster

    Hi Robert!

    Thanks for getting in touch with us! Let me help you with this topic.

    Yes, by default that is the expected behaviour to show the event cost.

    Like you say, you can customize the output of the cost function by using the tribe_get_cost filter available in https://github.com/moderntribe/the-events-calendar/blob/master/src/functions/template-tags/general.php#L819

    I hope that helps! 🙂

    Best,
    Victor

    #1507145
    Robert
    Participant

    Thanks, but repeating exactly what I already stated back to me and offering no actual guidance in how to do that did not help. Perhaps you can clarify on exactly how to do it? Even though it’s “default” behavior, I think one would agree that it’s not necessarily “right” behavior since it makes little to no sense to show a cost range if a ticket is no longer being shown.

    #1508153
    Victor
    Keymaster

    Hi Robert!

    Sure! Let me give you an example of the code.

    First, please let me note that we are fairly limited in <u>how much support we can give</u> for custom development questions like that.

    That said, we always like helping out and at least point users into the right direction as much possible.

    You can try to use the following and modify it to suit your needs:

    add_filter( 'tribe_get_cost', 'tribe_custom_cost', 10, 3 );
    
    function tribe_custom_cost ( $cost, $post_id, $with_currency_symbol ) {
    
       $event_id = 15; // Event id to target
       $cost_to_show = '$10 - $25'; // The custom cost to display
    
       if ( $post_id == $event_id ) {
          return $cost_to_show;
       }
    
       return $cost;
    }

    You can paste the code into your theme’s functions.php file.

    Best,
    Victor

    #1508249
    Robert
    Participant

    Thanks. While this does technically override the cost range, it’s a manual process it seems, where I’d have to replace the value each and every time with the ID. Hardly an effective solution…

    #1508988
    Victor
    Keymaster

    Hi Robert!

    If you want to apply this logic to all events, then you could further customize the snippet.

    I’ve just come up with another approach to only consider the ticket cost if the ticket is on sale:

    https://gist.github.com/vicskf/e9f4763809d825a2b768fe83a945c2fd

    It may need further tweaks, but I hope it serves as a starting point.

    Best,
    Victor

    #1509310
    Robert
    Participant

    Thanks Victor.

    How would I use that new function? Would it just override get_tribe_cost and I wouldn’t have to do anything else? I have yet to test it.

    #1509740
    Victor
    Keymaster

    Hi Robert,

    It works by replacing the tribe_get_cost() output but only for events that have tickets in it.

    I highly recommend to setup a dev/staging site so you can test things out and make sure it works as expected for your events, with different tickets setups.

    Hope it works for you 🙂

    Best,
    Victor

    #1526358
    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 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Cost range’ is closed to new replies.