MEC_HELPERS::get_event_tickets_cost()

Returns the tickets prices cost.

Contents


Return Return

(string) The comma separated ticket costs.


Source Source

File: src/integrations/modern-events-calendar/helpers/mec-helpers.php

	public function get_event_tickets_cost() {

		if ( ! class_exists( '\MEC_feature_books' ) && ! method_exists( '\MEC_feature_books', 'getBook' ) ) {
			return '';
		}

		if ( ! class_exists( '\MEC_main' ) && ! method_exists( '\MEC_main', 'render_price' ) ) {
			return '';
		}

		$mec_book = new \MEC_feature_books();
		$mec_main = new \MEC_main();

		$book = $mec_book->getBook();

		$event_tickets   = get_post_meta( $this->event_id, 'mec_tickets', true );
		$costs           = array();
		$attendees_count = 1; // Mocks the number of users. We need 1.

		if ( ! empty( $event_tickets ) ) {

			foreach ( $event_tickets as $id => $ticket ) {

				$raw_tickets   = array( $id => 1 );
				$price_details = $book->get_price_details( $raw_tickets, $event_id, $event_tickets, array() );
				$costs[]       = $mec_main->render_price( $price_details['total'] );

			}
		}

		return implode( ', ', $costs );

	}