Displaying event info on checkout & confirmation pages.

Home Forums Ticket Products Event Tickets Plus Displaying event info on checkout & confirmation pages.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #965830
    Joshua
    Participant

    Hello.

    I am using the following code to display the event info on the checkout page and similar code to do the same on the confirmation page. it displays the title with a link to the event, the start date/time, and the cost of the event.

    However, if I have two ticket prices for one event: General Admission & Reserved Seating, it will only display the highest price of that event but gives the correct totals.

    For example: GA is $20 and Reserved is $30
    If I choose 2 GA tickets and 2 RS tickets, it displays both as $30 X 2 when it should be displaying one $20 X 2 and one $30 X 2

    /**
     * Adding event info for the checkout pages
     * 
     */
    add_filter( 'woocommerce_cart_item_name', 'add_event_title_link', 10, 3 );
    
    function add_event_title_link( $title, $values, $cart_item_key ) {
      $ticket_meta = get_post_meta( $values['product_id'] );
      $event_id = absint( $ticket_meta['_tribe_wooticket_for_event'][0] );
    
      if ( $event_id ) {
        $title = sprintf( '%s <br /> <a href="%s" target="_blank"><strong>%s</strong></a> <br /> %s <br /> %s',
          $title,
          get_permalink( $event_id ),
          get_the_title( $event_id ),
          tribe_get_start_date( $event_id, false, 'F jS Y @ g:ia' ),
          tribe_get_formatted_cost( $event_id ));
    
      }
    
      return $title;
    }
    #966075
    George
    Participant

    Hey Joshua,

    This is an interesting customization, and though we can unfortunately only provide a very limited amount of support for such customizations, I think you should be able to get closer to what you’re seeking to do by not using that tribe_get_formatted_cost() function.

    That function is indeed useful, but if you want to get granular per-ticket pricing to display, your best option is to find the WooCommerce product IDs associated with the “tickets” for the events, and get the price of each ticket.

    As noted, we don’t offer full support for customizations so you’ll have to do a good amount of the work here on your own…BUT I do have a great example bit of code that you can check out to get started here.

    Check out this example function – it will get the Ticket meta for the tickets associated with an event:

    
    function dotdash_show_event_meta() {
    	
    	$event_id     = get_the_ID();
    	$tickets_meta = array();
    	$tribe_woo    = TribeWooTickets::get_instance();
    	
    	$tickets_ids = $tribe_woo->get_tickets_ids( $event_id );
    	
    	foreach ( $tickets_ids as $ticket_id ) {
    		$tickets_meta[] = $tribe_woo->get_ticket( $event_id, $ticket_id );
    	}
    
    	print '<h2>Tickets meta</h2>';
    	print '<pre>';
    	print_r( $tickets_meta );
    	print '</pre>';
    }
    

    Where you see the $tribe_woo->get_ticket( $event_id, $ticket_id ); function being called, you can use the return value of this function to get details about the ticket like price, etc., and go from there to display all the prices and other per-ticket info you’d need.

    I hope this helps! Keep good backups of your code before starting to customize it and play around with things a bit, I’m sure that as you get familiar with the meta structure of the products/tickets you’ll be able to piece something useful together here.

    Cheers,
    George

    #984219
    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 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Displaying event info on checkout & confirmation pages.’ is closed to new replies.