WordPress at Your Fingertips
function is not described

WC_API_Products::get_products() public WC 2.1

Get all products

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

No Hooks.

Return

Array.

Usage

$WC_API_Products = new WC_API_Products();
$WC_API_Products->get_products( $fields, $type, $filter, $page );
$fields(string)
-
Default: null
$type(string)
-
Default: null
$filter(array)
-
Default: array()
$page(int)
-
Default: 1

Changelog

Since 2.1 Introduced.

Code of WC_API_Products::get_products() WC 5.6.0

public function get_products( $fields = null, $type = null, $filter = array(), $page = 1 ) {

	if ( ! empty( $type ) ) {
		$filter['type'] = $type;
	}

	$filter['page'] = $page;

	$query = $this->query_products( $filter );

	$products = array();

	foreach ( $query->posts as $product_id ) {

		if ( ! $this->is_readable( $product_id ) ) {
			continue;
		}

		$products[] = current( $this->get_product( $product_id, $fields ) );
	}

	$this->server->add_pagination_headers( $query );

	return array( 'products' => $products );
}