WC_Product_Query
extends WC_Object_Query
in package
Product query class.
Extended by classes to provide a query abstraction layer for safe object searching.
Table of Contents
- $query_vars : array
- Stores query data.
- __construct() : mixed
- Create a new query.
- get() : mixed
- Get the value of a query variable.
- get_products() : array|object
- Get products matching the current query vars.
- get_query_vars() : array
- Get the current query vars.
- set() : mixed
- Set a query variable.
- get_default_query_vars() : array
- Valid query vars for products.
Properties
$query_vars
Stores query data.
protected
array
$query_vars
= array()
Methods
__construct()
Create a new query.
public
__construct([array $args = array() ]) : mixed
Parameters
- $args : array = array()
-
Criteria to query on in a format similar to WP_Query.
Return values
mixedget()
Get the value of a query variable.
public
get(string $query_var[, mixed $default = '' ]) : mixed
Parameters
- $query_var : string
-
Query variable to get value for.
- $default : mixed = ''
-
Default value if query variable is not set.
Return values
mixed — Query variable value if set, otherwise default.get_products()
Get products matching the current query vars.
public
get_products() : array|object
Return values
array|object — of WC_Product objectsget_query_vars()
Get the current query vars.
public
get_query_vars() : array
Return values
arrayset()
Set a query variable.
public
set(string $query_var, mixed $value) : mixed
Parameters
- $query_var : string
-
Query variable to set.
- $value : mixed
-
Value to set for query variable.
Return values
mixedget_default_query_vars()
Valid query vars for products.
protected
get_default_query_vars() : array