WC_API_Products::get_products()
Get all products
Метод класса: WC_API_Products{}
Хуков нет.
Возвращает
Массив
.
Использование
$WC_API_Products = new WC_API_Products(); $WC_API_Products->get_products( $fields, $type, $filter, $page );
- $fields(строка)
- -
По умолчанию: null - $type(строка)
- -
По умолчанию: null - $filter(массив)
- -
По умолчанию: array() - $page(int)
- -
По умолчанию: 1
Список изменений
С версии 2.1 | Введена. |
Код WC_API_Products::get_products() WC API Products::get products WC 7.5.1
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 ); }