WordPress at Your Fingertips
function is not described

WC_REST_CRUD_Controller::fetch_fields_using_getters() public WC 1.0

Get fields for an object if getter is defined.

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

No Hooks.


Array. Data fetched from getters.


$WC_REST_CRUD_Controller = new WC_REST_CRUD_Controller();
$WC_REST_CRUD_Controller->fetch_fields_using_getters( $object, $context, $fields );
$object(object) (required)
Object we are fetching response for.
$context(string) (required)
Context of the request. Can be view or edit.
$fields(array) (required)
List of fields to fetch.

Code of WC_REST_CRUD_Controller::fetch_fields_using_getters() WC 5.9.0

public function fetch_fields_using_getters( $object, $context, $fields ) {
	$data = array();
	foreach ( $fields as $field ) {
		if ( method_exists( $this, "api_get_$field" ) ) {
			$data[ $field ] = $this->{"api_get_$field"}( $object, $context );
	return $data;