Tribe__Events__API::update_event_cost( int $event_id, array|string|int $cost = array() )

Triggers an update of the cost meta data (min <-> max) for an event.

This is primarily for internal use where an addon needs to update the cost meta data for an event (but no other meta fields). To actually add to or modify the range of cost values the tribe_events_event_costs filter hook should be leveraged.


Parameters

$cost

(array|string|int) (Optional) Event cost.

Default value: array()

$event_id

(int) (Required) Event post ID.


Top ↑

Source

File: src/Tribe/API.php

		public static function update_event_cost( $event_id ) {
			// Loads current event costs, on construct
			// Tribe__Events__Tickets__Tickets->get_ticket_prices() adds them to this filter
			$event_cost = (array) apply_filters( 'tribe_events_event_costs', array(), $event_id );

			// Kill the old cost meta data
			delete_post_meta( $event_id, '_EventCost' );

			// Add fresh entries for each of the new values
			foreach ( $event_cost as $cost ) {
				add_post_meta( $event_id, '_EventCost', $cost );
			}
		}

Top ↑

Changelog

Changelog
Version Description
5.8.2 Introduced.