Add Price info to tooltips in Week and Month view

Home Forums Calendar Products Filter Bar Add Price info to tooltips in Week and Month view

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #967282
    wswebstuff
    Participant

    Continuing the conversation between Wendy & Gustavo regarding modding tooltips for Price.

    https://theeventscalendar.com/support/forums/topic/add-organizer-venue-and-price-info-to-tooltips-in-week-and-month-view/#post-946680

    https://theeventscalendar.com/support/forums/topic/add-organizer-venue-and-price-info-to-tooltips-in-week-and-month-view-2/

    I read through both of threads on this topic and I am having an issue with both the code that was shared in your previous conversations or by trying to implement the plugin posted.

    Following your templater’s guide, I was able to get Venue and Organizer set up with no issues. It is Price that is causing issues – the tooltip disappears completely.

    This works: https://gist.github.com/bordoni/439bd58bbfbb7db3454b
    This code (specifically the tickets/cost area) does not: https://gist.githubusercontent.com/bordoni/420661affe489e08fd5e/raw/9eaf796c62823ad6d82ef825b804ca8f7c0cfce7/plugin-tec-945349.php

    I have full access to my functions file and am running a child theme. I tried this with the default TwentyFifteen + TwentyFourteen themes and it is not working either. I am no longer running WooTickets + have the plugin fully uninstalled.

    Any advice? Could you explain what I’m supposed to call for when looking at price? Thanks!

    #967425
    Barry
    Member

    Hi there – sorry for the confusion!

    It looks like that custom tooltip.php template is actually based on our as yet-unreleased 3.10 code and therefore is triggering a breakage.

    Within that custom tooltip.php code, locate the .duration div which currently looks like this:

    <div class="duration">
    	<abbr class="tribe-events-abbr updated published dtstart">[[=dateDisplay]] </abbr>
    </div>

    Revise it to:

    <div class="duration">
    	<abbr class="tribe-events-abbr updated published dtstart">[[=startTime]] </abbr>
    	[[ if(endTime.length) { ]]
    	-<abbr class="tribe-events-abbr dtend"> [[=endTime]]</abbr>
    	[[ } ]]
    </div>

    That should prevent the tooltips from breaking altogether 🙂

    #967515
    wswebstuff
    Participant

    Hi Barry,

    Thanks for the help. I had caught that in my trials, and had left the code in tooltips.php untouched except to add:

    			[[ if(venue) { ]]
    			<p class="entry-venue">Venue: <a href="[[=venue_link]]">[[=venue_title]]</a></p>
    			[[ } ]]
    			[[ if(price) { ]]
    			<p class="entry-price">Price: [[=raw price]]</a></p>
    			[[ } ]]

    I’m thinking it might be my functions.php code that needs the tweak:

    //*-- Add Cost to Tooltip *//
    function post_cost_tribe( $json, $event, $additional ){
    
    	$venue = tribe_get_venue_id( $event );
    	if ( $venue ){
    		$json['venue'] = $venue;
    		$json['venue_link'] = tribe_get_venue_link( $venue, false );
    		$json['venue_title'] = tribe_get_venue( $venue );
    	}
    
    	if ( function_exists( 'wootickets_init' ) ){
    		$tickets = TribeWooTickets::get_instance()->get_tickets_ids( $event );
    		if ( ! empty( $tickets ) ){
    			$min = PHP_INT_MAX;
    			$max = -1;
    
    			foreach ( $tickets as $ticket ) {
    				$ticket = TribeWooTickets::get_instance()->get_ticket( $event, $ticket );
    				$min = min( array( $min, $ticket->price ) );
    				$max = max( array( $max, $ticket->price ) );
    			}
    
    			if ( $min == $max ){
    				$json['price'] = wc_price( $min );
    			} else {
    				$json['price'] = 'from ' . wc_price( $min ) . ' to ' . wc_price( $max );
    			}
    		}
    	}
    
    	return $json;
    }
    add_filter( 'tribe_events_template_data_array', 'post_cost_tribe', 10, 3 );

    I’m sorry I didn’t include my code in the first round of questions.

    Here is my full tooltip code:

    <script type="text/html" id="tribe_tmpl_tooltip">
    	<div id="tribe-events-tooltip-[[=eventId]]" class="tribe-events-tooltip">
    		<h4 class="entry-title summary">[[=title]]</h4>
    
    		<div class="tribe-events-event-body">
    			<div class="duration">
    				<abbr class="tribe-events-abbr updated published dtstart">[[=startTime]] </abbr>
    				[[ if(endTime.length) { ]]
    				-<abbr class="tribe-events-abbr dtend"> [[=endTime]]</abbr>
    				[[ } ]]
    			</div>
    			[[ if(imageTooltipSrc.length) { ]]
    			<div class="tribe-events-event-thumb">
    				<img src="[[=imageTooltipSrc]]" alt="[[=title]]" />
    			</div>
    			[[ } ]]
    			[[ if(excerpt.length) { ]]
    			<p class="entry-summary description">[[=raw excerpt]]</p>
    			[[ } ]]
    			[[ if(venue) { ]]
    			<p class="entry-venue">Venue: <a href="[[=venue_link]]">[[=venue_title]]</a></p>
    			[[ } ]]
    			[[ if(price) { ]]
    			<p class="entry-price">Price: [[=raw price]]</a></p>
    			[[ } ]]
    			<span class="tribe-events-arrow"></span>
    		</div>
    	</div>
    </script>
    #967564
    Barry
    Member

    Thanks for the extra details 🙂

    The problem here is your code doesn’t guarantee that the price or venue vars will be defined – but your modified tooltip template expects them always to be set.

    How about changing things so that if there is no venue or price you instead define an empty variable and then – a bit like you can see elsewhere in the default tooltip template – test for a positive length value?

    #971842
    Barry
    Member

    Hi!

    It’s been a while so I’m going to go ahead and close this topic.

    • Need help with anything else? Go right ahead and post a new topic, one of the team will be only too happy to help
    • Still need help with this issue and need to re-open it? Again, please simply create a new topic and link to this one to provide the team with some context

    Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Add Price info to tooltips in Week and Month view’ is closed to new replies.