Advertisement
eventsmanager

Custom Multiple Price Range

Oct 23rd, 2014
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. /*
  2. Sample output: FREE - $1.00 - $2.00 - $3.00
  3. */
  4. add_filter('em_event_output_placeholder','my_em_placeholder_mod_price',1,3);
  5. function my_em_placeholder_mod_price($replace, $EM_Event, $result){
  6. if ( $result == '#_EVENTPRICERANGE' ) {
  7. $min = false;
  8. $max = 0;
  9. $prices = array();
  10. if( $EM_Event->get_bookings()->is_open() || !empty($show_all_ticket_prices) ){
  11. foreach( $EM_Event->get_tickets()->tickets as $EM_Ticket ){
  12. /* @var $EM_Ticket EM_Ticket */
  13. if( $EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable') || !empty($show_all_ticket_prices) ){
  14. if($EM_Ticket->get_price() > $max ){
  15. $max = $EM_Ticket->get_price();
  16. }
  17. if($EM_Ticket->get_price() < $min || $min === false){
  18. $min = $EM_Ticket->get_price();
  19. }
  20. if ($EM_Ticket->get_price() > 0){
  21. array_push($prices, em_get_currency_formatted($EM_Ticket->get_price()));
  22. }
  23. }
  24. }
  25. }
  26. if( $min === false ) $min = 0;
  27. if( $min != $max ){
  28. sort($prices);
  29. $replace = ($min > 0) ? implode(" - ", $prices):'FREE'.' - '.implode(" - ", $prices);
  30. }else{
  31. $replace = ($min > 0) ? em_get_currency_formatted($min):'FREE';
  32. }
  33. }
  34. return $replace;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement