eventsmanager icon

Adding charges to gateways

eventsmanager | PRO | 03/10/24 08:15:26 AM UTC (Edited) | 0 ⭐ | 707 👁️ | Never ⏰ | []
text |

670 B

|

None

|

0 👍

/

0 👎

<?php
  function my_em_price_adjustments_2( $EM_Event, $EM_Booking, $post_validation ){
	if( $post_validation ){
		$EM_Booking->booking_meta['surcharges'] = array();
		$EM_Tickets_Bookings = $EM_Booking->get_tickets_bookings();
		$label = "Charges";
 		$amount = 0;
		foreach( $EM_Tickets_Bookings->tickets_bookings as $EM_Ticket_Booking ){
 			$amount += ($EM_Ticket_Booking->get_ticket()->ticket_price * .2);
 		}
		if ( $amount > 0 ){
			$EM_Booking->booking_meta['surcharges'][] = array(
			'name' => $label,
			'type' => '#',
			'amount' => $amount,
			'tax' => 'pre'
			);
		}
	}
}
add_action('em_booking_add', 'my_em_price_adjustments_2', 100, 3);

Comments