booking_meta['surcharges']) ) $EM_Booking->booking_meta['surcharges'] = array(); if( empty($EM_Booking->booking_meta['discounts']) ) $EM_Booking->booking_meta['discounts'] = array(); // Add some adjustments, note that we're adding unique keys to the pricing adjustments, so that if we need to add/recalculate we don't add more than once. //Example Surcharges //This one adds a fixed $25 surcharge and is applied before taxes $EM_Booking->booking_meta['surcharges']['special'] = array( 'name' => 'Special Surcharge', 'desc' => 'Some type of surcharge description', 'type' => '#', //numerical discount i.e. $10.00 off 'amount' => '25.00', 'tax' => 'pre' //discount applied BEFORE taxes have been added, and IS taxable ); //This one adds a %3 surcharge, and is applied after taxes. $EM_Booking->booking_meta['surcharges']['handling_fee'] = array( 'name' => 'Handling Fee', 'desc' => 'Some type of surcharge description', 'type' => '%', //percentage discount of total price after taxes i.e. %3 extra 'amount' => '3.00', 'tax' => 'post' //discount applied AFTER taxes have been added, and IS NOT taxable ); //Example Discounts //This one adds a %3 discount before taxes have been applied. $EM_Booking->booking_meta['discounts']['handling_fee'] = array( 'name' => 'Handling Fee Discount', 'desc' => 'Some type of surcharge description', 'type' => '%', //percentage discount of total price after taxes i.e. %3 extra 'amount' => '3.00', 'tax' => 'pre' //discount applied BEFORE taxes have been added, and IS taxable ); //This oadds a $10 discount after taxes have been applied $EM_Booking->booking_meta['discounts']['super_special'] = array( 'name' => 'Super Special Discount', 'desc' => 'Some type of discount description', 'type' => '#', //numerical discount i.e. $10.00 off 'amount' => '10.00', 'tax' => 'post' //discount applied AFTER taxes have been added, and IS NOT taxable ); } $EM_Booking->calculate_price(); return $result; } /** * Example function for handling discounts and surcharges within Multiple Bookings. Adjustments are made (and can currently only be made) to the multiple booking object, not individual bookings. * @param EM_Multiple_Booking Multiple Booking object, containing individual bookings within. * @param mixed $booking_data - Supplied information to create EM_Multiple_Booking object. * @return bool * @see EM_Price_Adjustments::add_price_adjustments() */ public static function add_mb_price_adjustments( $event_id, $EM_Booking, $EM_Multiple_Booking ){ //$bookings_data must be empty here, because otherwise it means this booking object already existed at one point. return static::add_price_adjustments(true, $EM_Multiple_Booking); } /** * Adds price adjustments to default pre-selected tickets, which is reflected on page load in booking summary. * @param EM_Booking $EM_Booking * @return EM_Booking * @see EM_Price_Adjustments::add_price_adjustments() */ public static function get_intent_default( $EM_Booking ){ if( $EM_Booking ) { static::add_price_adjustments( true, $EM_Booking ); return $EM_Booking; } return $EM_Booking; } } EM_Price_Adjustments::init();