AMELIABOOKING_TOKENS::save_token_data_reservation( $args,  $trigger )

Method save_token_data_reservation.


Description Description

Save the reservation data to trigger log meta before trigger is completed.


Top ↑

Return Return

(void)


Source Source

File: src/integrations/ameliabooking/tokens/ameliabooking-tokens.php

	public function save_token_data_reservation( $args, $trigger ) {

		if ( ! isset( $args['trigger_args'] ) || ! isset( $args['entry_args']['code'] ) ) {
			return;
		}

		// Check if trigger code is for Amelia.
		if ( in_array( $args['entry_args']['code'], self::RESERVATION_TOKENS_TRIGGERS, true ) ) {

			$helper = Automator()->helpers->recipe->ameliabooking->options;

			$reservation = array_shift( $args['trigger_args'] );

			$reservation['event']['date'] = $helper->get_event_date( $reservation );

			$reservation['event']['tags'] = $helper->get_event_tags( $reservation );

			$reservation['event']['staff'] = $helper->get_event_staff( $reservation );

			$reservation['event']['organizer'] = $helper->get_event_organizer( $reservation['event']['organizerId'] );

			Automator()->db->token->save( 'AMELIA_RESERVATION_DATA', wp_json_encode( $reservation ), $args['trigger_entry'] );

		}

	}