Advertisement
StonehengeCreations

EM Pro - Add Surcharge per ticket

Feb 25th, 2020
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. function stonehenge_em_add_surcharge( $EM_Event, $EM_Booking, $post_validation ) {
  2.     if( $post_validation ) {
  3.         if( empty($EM_Booking->booking_meta['surcharges']) ) $EM_Booking->booking_meta['surcharges'] = array();
  4.             $spaces     = $EM_Booking->spaces;
  5.             $netto      = '5.00';
  6.             $tax_rate   = $EM_Booking->booking_tax_rate;
  7.             $tax_perc   = ($tax_rate/100);
  8.             $bruto      = ($netto / (1 + $tax_perc));
  9.             $total      = number_format( ($bruto * $spaces), 4);
  10.  
  11.             $EM_Booking->booking_meta['surcharges'][] = array(
  12.                 'name'      => sprintf('Vollkasko für %d Personen', $spaces),
  13.                 'desc'      => '',
  14.                 'type'      => '#',
  15.                 'amount'    => $total,
  16.                 'tax'       => 'pre'
  17.             );
  18.         }
  19.     }
  20. add_action('em_booking_add', 'stonehenge_em_add_surcharge', 11, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement