Shortcode for remaining tickets

This topic contains 6 replies, has 3 voices, and was last updated by  Stephen Harris 5 months, 1 week ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #17094

    Hi Stephhen,

    Is it possible to add the remaining ticket count (%remaining_ticket% ) to this shortcode example which shows a list of future events? I am currently selling by date.

    [eo_events event_end_after=now]

     <div class="evlistWrap"> 
          <div class="eo-date-container">
               <span>%start{M}%</span> <span>%start{j}%</span>
          </div> 
          <div class="evList"> 
               <h2><a href="%event_url%">%event_title%</a></h2> 
          </div> 
          <div><a href="%event_url%">aanmelden</a></div> 
     </div>
    

    [/eo_events]

    I have tried making a shortcode for this, but till now have had no luck with it. What do I need to write and where?

    Regards, Tony

    Tony
    #17118

    Hi Tony,

    I think that would make an excellent addition for the event list shortcode, so I’ll look into this over the weekend with a view of incorporating this into a future update.

    If there’s a ‘quick fix’ for you for the immediate future then I’ll let you know here.

    Stephen Harris
    #17165

    Hi Tony,

    Unfortunately support for that tag may be a while off. How Event Organiser registers and parses those tags is in need of a rethink, but this would mean its in Event Organiser 3.0.0.

    An immediate solution is to use a template file rather than the placeholder tags. E.g if you edit shortcode-event-list.php so that each event (within the while loop) has the following structure:

     <div class="evlistWrap"> 
          <div class="eo-date-container">
               <span><?php eo_the_start('M');?></span> 
               <span><?php eo_the_start('j');?></span>
          </div> 
          <div class="evList"> 
               <h2><a href="<?php echo esc_url( get_permalink() );?>"><?php the_title();?></a></h2> 
          </div> 
          <div>
              <a href="<?php echo esc_url( get_permalink() );?>">aanmelden</a>
              <?php printf( 
                  '%s tickets remaining', 
                  eo_get_remaining_tickets_count( get_the_ID(), eo_get_the_occurrence_id() ) 
              );?>
          </div> 
     </div>
    
    Stephen Harris
    #37464

    Hi, how can i display the remaining tickets on the admin email in booking-actions.php ?

    thank u

    Serkan Sen
    #37473

    Hi Serkan,

    You can modify the content of the email sent to admins when a booking is configured with the eventorganiser_notify_confirmed_booking_message filter (for new bookings that are not necessarily confirmed you can use eventorganiser_notify_new_booking_message).

    This code will add a line which displaying the number of remaining tickets using a custom template tag (which we will define):

    add_filter('eventorganiser_notify_confirmed_booking_message', function($email_content){
            return $email_content . '<p>Remaining tickets %_remaining_tickets%</p>';
    });
    

    Next we just need to define that custom tag:

    add_action('init', function(){
            \EO_Email_Template_Tag_Registry::register( '_remaining_tickets', function($tag, $atts, $context) {
                    $event_id = $context['event_id'];
                    $occurrence_id = isset($context['occurrence_id']) ? $context['occurrence_id'] : 0;
                    return eo_get_remaining_tickets_count($event_id, $occurrence_id);
            });
    });
    
    Stephen Harris
    #37488

    Hi Stephen,

    thank u very much. It worked.

    I edited booking-actions.php before. How can i put my changes for new booking message, that i have everything in functions.php and overwrite it?

    The changes in booking-actions.php are only in variable $message.

    A second question: When i export the bookings, the csv doesnt show me the german characters (ä,ö,ü etc) Is there any solution for this?

    thank u in advance
    Serkan

    Serkan Sen
    #37551

    So $message is actually $email_content above – just given a different name.

    How do the characters appear? Or are they missing entirely?

    Stephen Harris
Viewing 7 posts - 1 through 7 (of 7 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.