Tribe__Events__Editor__Meta::update_cost( stdClass $post_data, WP_REST_Request $request )

Make sure we allow other plugins and customizations to filter the cost field.


Parameters

$post_data

(stdClass) (Required) The post insertion/update payload.

$request

(WP_REST_Request) (Required) The current insertion or update request object.


Top ↑

Return

(stdClass) The post insertion/update payload.


Top ↑

Source

File: src/Tribe/Editor/Meta.php

	public function update_cost( $post_data, $request ) {
		$post_id = $request->get_param( 'id' );

		// Fetch cost data from the request (if set).
		$json = $request->get_json_params();

		$meta = Tribe__Utils__Array::get( $json, 'meta', [] );

		// If the cost is set in the submitted data, set THAT as the default else set an appropriate default for the cost.
		$cost = isset( $meta['_EventCost'] ) ? [ $meta['_EventCost'] ] : (array) tribe_get_cost( $post_id );

		// Update the cost for the event.
		\Tribe__Events__API::update_event_cost( $post_id, $cost );

		return $post_data;
	}

Top ↑

Changelog

Changelog
Version Description
5.7.1 Introduced.