<?php
function my_em_add_price_adjustments( $EM_Event, $EM_Booking, $post_validation ){
//Only apply surcharge if booking has passed validation and therefore can be saved to database
//You could also do further checks here if you want to give discounts to specific events or bookings
if( $post_validation ){
//Ensure we have arrays assigned to booking meta, if not create them to avoid PHP warnings
if( empty($EM_Booking->booking_meta['surcharges']) ) $EM_Booking->booking_meta['surcharges'] = array();
//This one adds a fixed $25 surcharge and is applied before taxes
$prix = $EM_Booking->get_price_pre_taxes();
$pourcentage = 3;
$fixe = 0.35;
$amount = ($prix * ($pourcentage/100)) + $fixe;
$EM_Booking->booking_meta['surcharges'][] = array(
'name' => 'Frais Paypal',
'desc' => 'Frais Paypal',
'type' => '#', //numerical discount i.e. $10.00 off
'amount' => $amount,
'tax' => 'pre' //discount applied BEFORE taxes have been added, and IS taxable
);
}
}
add_action('em_booking_add', 'my_em_add_price_adjustments', 10, 3);
?>
Comments