Ameliabooking_Helpers::ameliabooking_service_category_endpoint()

Callback method to wp_ajax_ameliabooking_service_category_endpoint.


Return Return

(void)


Source Source

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

	public function ameliabooking_service_category_endpoint() {

		Automator()->utilities->ajax_auth_check();

		$category_id = absint( automator_filter_input( 'value', INPUT_POST ) );

		$items = array(
			array(
				'text'  => esc_html__( 'Any service', 'uncanny-automator' ),
				'value' => '-1',
			),
		);

		$services = $this->get_services_by_category( $category_id );

		if ( ! empty( $services ) ) {
			foreach ( $services as $service ) {
				$items[] = array(
					'text'  => $service->name,
					'value' => $service->id,
				);
			}
		}

		wp_send_json( $items );

	}