WordPress at Your Fingertips
function is not described

WC_REST_Coupons_V2_Controller::prepare_objects_query() protected WC 3.0.0

Prepare objects query.

{} It's a method of the class: WC_REST_Coupons_V2_Controller{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_objects_query( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Changelog

Since 3.0.0 Introduced.

Code of WC_REST_Coupons_V2_Controller::prepare_objects_query() WC 5.9.0

protected function prepare_objects_query( $request ) {
	$args = parent::prepare_objects_query( $request );

	if ( ! empty( $request['code'] ) ) {
		$id               = wc_get_coupon_id_by_code( $request['code'] );
		$args['post__in'] = array( $id );
	}

	// Get only ids.
	$args['fields'] = 'ids';

	return $args;
}