eventsmanager

Add Payment Gateway Used and Transaction ID to my-bookings

Apr 2nd, 2017
464
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. This snippet will do the following:
  3. 1. Change header "Spaces" to "Tickets"
  4. 2. add payment gateway used and payment gateway transaction id
  5.  
  6. to use templates: http://wp-events-plugin.com/documentation/using-template-files/
  7. eg. wp-content/themes/Your Theme/plugins/events-manager/templates/my-bookings.php
  8.  
  9. Then paste the whole snippet below
  10.  
  11. */
  12.  
  13. <?php do_action('em_template_my_bookings_header'); ?>
  14. <?php
  15. global $wpdb, $current_user, $EM_Notices, $EM_Person;
  16. if( is_user_logged_in() ):
  17. $EM_Person = new EM_Person( get_current_user_id() );
  18. $EM_Bookings = $EM_Person->get_bookings();
  19. $bookings_count = count($EM_Bookings->bookings);
  20. if($bookings_count > 0){
  21. //Get events here in one query to speed things up
  22. $event_ids = array();
  23. foreach($EM_Bookings as $EM_Booking){
  24. $event_ids[] = $EM_Booking->event_id;
  25. }
  26. }
  27. $limit = ( !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
  28. $page = ( !empty($_GET['pno']) ) ? $_GET['pno']:1;
  29. $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
  30. echo $EM_Notices;
  31. ?>
  32. <div class='em-my-bookings'>
  33. <?php if ( $bookings_count >= $limit ) : ?>
  34. <div class='tablenav'>
  35. <?php
  36. if ( $bookings_count >= $limit ) {
  37. $link = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%'), false); //don't html encode, so em_paginate does its thing
  38. $bookings_nav = em_paginate( $link, $bookings_count, $limit, $page);
  39. echo $bookings_nav;
  40. }
  41. ?>
  42. <div class="clear"></div>
  43. </div>
  44. <?php endif; ?>
  45. <div class="clear"></div>
  46. <?php if( $bookings_count > 0 ): ?>
  47. <div class='table-wrap'>
  48. <table id='dbem-bookings-table' class='widefat post fixed'>
  49. <thead>
  50. <tr>
  51. <th class='manage-column' scope='col'><?php _e('Event', 'events-manager'); ?></th>
  52. <th class='manage-column' scope='col'><?php _e('Date', 'events-manager'); ?></th>
  53. <th class='manage-column' scope='col'><?php _e('Tickets', 'events-manager'); ?></th>
  54. <th class='manage-column' scope='col'><?php _e('Payment Gateway', 'events-manager'); ?></th>
  55. <th class='manage-column' scope='col'><?php _e('Transaction ID', 'events-manager'); ?></th>
  56. <th class='manage-column' scope='col'><?php _e('Status', 'events-manager'); ?></th>
  57. <th class='manage-column' scope='col'>&nbsp;</th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. <?php
  62. $rowno = 0;
  63. $event_count = 0;
  64. $nonce = wp_create_nonce('booking_cancel');
  65. foreach ($EM_Bookings as $EM_Booking) {
  66. /* @var $EM_Booking EM_Booking */
  67. $EM_Event = $EM_Booking->get_event();
  68. if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
  69. $rowno++;
  70. ?>
  71. <tr>
  72. <td><?php echo $EM_Event->output("#_EVENTLINK"); ?></td>
  73. <td><?php echo date_i18n( get_option('dbem_date_format'), $EM_Event->start ); ?></td>
  74. <td><?php echo $EM_Booking->get_spaces() ?></td>
  75. <td><?php echo $EM_Booking->output("#_PAYMENTGATEWAY"); ?></td>
  76. <td><?php echo $EM_Booking->output("#_PAYMENTGATEWAYTRANSID"); ?></td>
  77. <td>
  78. <?php echo $EM_Booking->get_status(); ?>
  79. </td>
  80. <td>
  81. <?php
  82. $cancel_link = '';
  83. if( !in_array($EM_Booking->booking_status, array(2,3)) && get_option('dbem_bookings_user_cancellation') && $EM_Event->get_bookings()->has_open_time() ){
  84. $cancel_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'booking_cancel', 'booking_id'=>$EM_Booking->booking_id, '_wpnonce'=>$nonce));
  85. $cancel_link = '<a class="em-bookings-cancel" href="'.$cancel_url.'" onclick="if( !confirm(EM.booking_warning_cancel) ){ return false; }">'.__('Cancel','events-manager').'</a>';
  86. }
  87. echo apply_filters('em_my_bookings_booking_actions', $cancel_link, $EM_Booking);
  88. ?>
  89. </td>
  90. </tr>
  91. <?php
  92. }
  93. do_action('em_my_bookings_booking_loop',$EM_Booking);
  94. $event_count++;
  95. }
  96. ?>
  97. </tbody>
  98. </table>
  99. </div>
  100. <?php else: ?>
  101. <?php _e('You do not have any bookings.', 'events-manager'); ?>
  102. <?php endif; ?>
  103. <?php if( !empty($bookings_nav) && $bookings_count >= $limit ) : ?>
  104. <div class='tablenav'>
  105. <?php echo $bookings_nav; ?>
  106. <div class="clear"></div>
  107. </div>
  108. <?php endif; ?>
  109. </div>
  110. <?php do_action('em_template_my_bookings_footer', $EM_Bookings); ?>
  111. <?php else: ?>
  112. <p><?php echo sprintf(__('Please <a href="%s">Log In</a> to view your bookings.','events-manager'),site_url('wp-login.php?redirect_to=' . urlencode(get_permalink()), 'login'))?></p>
  113. <?php endif; ?>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×