Automattic\WooCommerce\Internal\ProductFeed\Integrations\POSCatalog

ProductMapper::get_products_requestprotectedWC 1.0

Get the REST request instance for products.

Метод класса: ProductMapper{}

Хуков нет.

Возвращает

WP_REST_Request<Массив<Строку,. mixed>>

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_products_request(): WP_REST_Request;

Код ProductMapper::get_products_request() WC 10.5.2

protected function get_products_request(): WP_REST_Request {
	if ( null === $this->products_request ) {
		/**
		 * Type hint for PHPStan generics.
		 *
		 * @var WP_REST_Request<array<string, mixed>> $request
		 * */
		$request                = new WP_REST_Request( 'GET' );
		$this->products_request = $request;
		$this->products_request->set_param( 'context', 'view' );

		if ( null !== $this->fields ) {
			$this->products_request->set_param( '_fields', $this->fields );
		}
	}

	return $this->products_request;
}

/**
 * Get the REST request instance for variations.
 *
 * @return WP_REST_Request<array<string, mixed>>
 */
protected function get_variations_request(): WP_REST_Request {
	if ( null === $this->variations_request ) {
		/**
		 * Type hint for PHPStan generics.
		 *
		 * @var WP_REST_Request<array<string, mixed>> $request
		 */
		$request                  = new WP_REST_Request( 'GET' );
		$this->variations_request = $request;
		$this->variations_request->set_param( 'context', 'view' );

		if ( null !== $this->variation_fields ) {
			$this->variations_request->set_param( '_fields', $this->variation_fields );
		}
	}

	return $this->variations_request;
}
}