Advertisement
eventsmanager

Custom template for cart-table.php

Aug 18th, 2014
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.12 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * this custom template will add Unit Price in the ticket details (clicking Details+ in the cart)
  5. *
  6. *1. create template directory or folders to wp-content > themes > Your Theme > plugins > events-manager-pro > multiple-bookings
  7. *2. inside directory at #1 create new php file and name it as cart-table.php
  8. *3. paste this snippet
  9. *
  10. *path should be wp-content > themes > Your Theme > plugins > events-manager-pro > multiple-bookings > cart-table.php
  11. */
  12.  
  13. /*
  14. * WARNING -This is a recently added template (2013-01-30), and is likly to change as we fine-tune things over the coming weeks/months, if at all possible try to use our hooks or CSS/jQuery to acheive your customizations
  15. * This displays the booking cart showing the persons bookings, attendees and a breakdown of pricing.
  16. * You can override the default display settings pages by copying this file to yourthemefolder/plugins/events-manager-pro/multiple-bookings/ and modifying it however you need.
  17. * For more information, see http://wp-events-plugin.com/documentation/using-template-files/
  18. */
  19. if(empty($EM_Multiple_Booking)) $EM_Multiple_Booking = EM_Multiple_Bookings::get_multiple_booking();
  20. if( empty($EM_Multiple_Booking->bookings) ){
  21. echo get_option('dbem_multiple_bookings_feedback_no_bookings');
  22. return;
  23. }
  24. //TODO make bookings editable
  25. //echo "<pre>"; print_r($EM_Multiple_Booking->booking_meta); echo "</pre>";
  26. ?>
  27. <div class="em-cart-table">
  28. <table>
  29. <tbody class="em-cart-summary">
  30. <?php do_action('em_cart_form_before_events', $EM_Multiple_Booking); //do not delete ?>
  31. <tr class="em-cart-title">
  32. <th class="em-cart-title-event"><?php esc_html_e('Event','em-pro'); ?></th>
  33. <th class="em-cart-title-spaces"><?php esc_html_e('Spaces','em-pro'); ?></th>
  34. <th class="em-cart-title-spaces"><?php esc_html_e('Unit Price','em-pro'); ?></th>
  35. <th class="em-cart-title-price"><?php esc_html_e('Price','dbem'); ?></th>
  36. </tr>
  37. <?php foreach($EM_Multiple_Booking->get_bookings() as $EM_Booking): /* @var $EM_Booking EM_Booking */ ?>
  38. <tr class="em-cart-table-event-summary" id="em-cart-table-event-summary-<?php echo $EM_Booking->get_event()->event_id; ?>">
  39. <td>
  40. <?php ob_start(); ?>
  41. <span class="em-cart-table-event-title">#_EVENTLINK</span><br/>
  42. <?php esc_html_e('When','em-pro'); ?> : #_EVENTDATES @ #_EVENTTIMES<br />
  43. <?php esc_html_e('Where','em-pro'); ?> : #_LOCATIONFULLLINE
  44. <?php echo $EM_Booking->output(ob_get_clean()); ?><br />
  45. <div class="em-cart-table-details-actions">
  46. <!-- <a href="#" class="em-cart-table-actions-edit" rel="<?php echo $EM_Booking->get_event()->event_id; ?>" id="em-cart-table-actions-edit-<?php echo $EM_Booking->get_event()->event_id; ?>">
  47. <?php esc_html_e('edit','em-pro'); ?>
  48. </a>&nbsp; --->
  49. <a href="#" class="em-cart-table-actions-remove" rel="<?php echo $EM_Booking->get_event()->event_id; ?>" id="em-cart-table-actions-remove-<?php echo $EM_Booking->get_event()->event_id; ?>">
  50. <?php esc_html_e('remove','em-pro'); ?>
  51. </a>
  52. </div>
  53. <div class="em-cart-table-details-triggers">
  54. <a href="#" class="em-cart-table-details-show" rel="<?php echo $EM_Booking->get_event()->event_id; ?>" id="em-cart-table-details-show-<?php echo $EM_Booking->get_event()->event_id; ?>">
  55. + <?php esc_html_e('details','em-pro'); ?>
  56. </a>
  57. <a href="#" class="em-cart-table-details-hide" rel="<?php echo $EM_Booking->get_event()->event_id; ?>" id="em-cart-table-details-hide-<?php echo $EM_Booking->get_event()->event_id; ?>">
  58. - <?php esc_html_e('details','em-pro'); ?>
  59. </a>
  60. </div>
  61. <?php
  62. //get booking form information (aside from attendee info
  63. $booking_data = EM_Booking_Form::get_booking_data($EM_Booking);
  64. if( count($booking_data['booking']) ){
  65. ?>
  66. <div class="em-cart-table-event-details em-cart-table-event-details-<?php echo $EM_Booking->get_event()->event_id; ?> em-cart-info">
  67. <div class="em-cart-info-booking-title"><?php esc_html_e('Booking Information','em-pro') ?></div>
  68. <div class="em-cart-info-values">
  69. <?php foreach( $booking_data['booking'] as $booking_label => $booking_value ): ?>
  70. <label><?php echo $booking_label; ?> :</label>
  71. <span><?php echo $booking_value; ?></span><br />
  72. <?php endforeach; ?>
  73. </div>
  74. </div>
  75. <?php } ?>
  76. </td>
  77. <td class="em-cart-table-spaces"><span><?php echo $EM_Booking->get_spaces(); ?></span></td>
  78. <td class="em-cart-table-price"></td>
  79. <td class="em-cart-table-price"><span><?php echo $EM_Booking->get_price_base(true); ?></span></td>
  80. </tr>
  81. <!-- BEGIN Subtotal Tickets for Event -->
  82. <?php $attendee_datas = EM_Attendees_Form::get_booking_attendees($EM_Booking); ?>
  83. <?php foreach( $EM_Booking->get_tickets_bookings() as $EM_Ticket_Booking ): ?>
  84. <tr class="em-cart-table-event-details em-cart-table-event-details-<?php echo $EM_Booking->get_event()->event_id; ?>" id="em-cart-row-<?php echo $EM_Booking->get_event()->event_id; ?>-<?php echo $EM_Ticket_Booking->get_ticket()->ticket_id; ?>">
  85. <td>
  86. <div class="em-cart-table-ticket"><?php echo $EM_Ticket_Booking->get_ticket()->ticket_name; ?></div>
  87. <?php //BEGIN Attendee Info (if applicable) ?>
  88. <?php foreach( EM_Attendees_Form::get_ticket_attendees($EM_Ticket_Booking) as $attendee_title => $attendee_data): ?>
  89. <div class="em-cart-info">
  90. <span class="em-cart-info-title"><?php echo $attendee_title; ?></span>
  91. <div class="em-cart-info-values">
  92. <?php
  93. foreach( $attendee_data as $attendee_label => $attendee_value ){
  94. ?>
  95. <label><?php echo $attendee_label; ?> :</label>
  96. <span><?php echo $attendee_value; ?></span><br />
  97. <?php
  98. }
  99. ?>
  100. </div>
  101. </div>
  102. <?php endforeach; ?>
  103. <?php //END Attendee Info ?>
  104. </td>
  105. <td class="em-cart-table-spaces"><?php echo $EM_Ticket_Booking->get_spaces(); ?></td>
  106. <td class="em-cart-table-price"><?php echo $EM_Ticket_Booking->get_ticket()->ticket_price; ?></td>
  107. <td class="em-cart-table-price"><?php echo $EM_Ticket_Booking->get_price(true); ?></td>
  108. </tr>
  109. <?php endforeach; ?>
  110. <!-- END Subtotal Tickets for Event -->
  111. <?php endforeach; ?>
  112. <?php do_action('em_cart_form_after_events', $EM_Multiple_Booking); //do not delete ?>
  113. </tbody>
  114. <tbody class="em-cart-totals">
  115. <?php
  116. do_action('em_cart_form_before_totals', $EM_Multiple_Booking); //do not delete
  117. $price_summary = $EM_Multiple_Booking->get_price_summary_array();
  118. //we should now have an array of information including base price, taxes and post/pre tax discounts
  119. ?>
  120. <tr>
  121. <th colspan="2"><?php esc_html_e('Sub Total','em-pro'); ?></th>
  122. <td><?php echo $EM_Multiple_Booking->get_price_base(true); ?></td>
  123. </tr>
  124. <?php if( count($price_summary['discounts_pre_tax']) > 0 ): ?>
  125. <?php foreach( $price_summary['discounts_pre_tax'] as $discount_summary ): ?>
  126. <tr>
  127. <th colspan="2"><?php echo $discount_summary['name']; ?></th>
  128. <td>- <?php echo $discount_summary['amount']; ?></td>
  129. </tr>
  130. <?php endforeach; ?>
  131. <?php endif; ?>
  132. <?php if( !empty($price_summary['taxes']['amount']) ): ?>
  133. <tr>
  134. <th colspan="2"><?php esc_html_e('Taxes','em-pro'); ?> ( <?php echo $price_summary['taxes']['rate']; ?> )</th>
  135. <td><?php echo $price_summary['taxes']['amount']; ?></td>
  136. </tr>
  137. <?php endif; ?>
  138. <?php if( count($price_summary['discounts_post_tax']) > 0 ): ?>
  139. <?php foreach( $price_summary['discounts_post_tax'] as $discount_summary ): ?>
  140. <tr>
  141. <th colspan="2"><?php echo $discount_summary['name']; ?></th>
  142. <td>- <?php echo $discount_summary['amount']; ?></td>
  143. </tr>
  144. <?php endforeach; ?>
  145. <?php endif; ?>
  146. <tr>
  147. <th colspan="2"><?php esc_html_e('Total Price','dbem'); ?></th>
  148. <td><?php echo $price_summary['total']; ?></td>
  149. </tr>
  150. <?php do_action('em_cart_form_after_totals', $EM_Multiple_Booking); //do not delete ?>
  151. </tbody>
  152. </table>
  153. </div>
  154. <?php do_action('em_cart_footer', $EM_Multiple_Booking); //do not delete ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement