Class WC_Query

WC_Query Class

Package: WooCommerce\Classes
Author: WooThemes
Located at includes/class-wc-query.php

Methods summary

public
# __construct( )

Constructor for the query class. Hooks in methods.

Constructor for the query class. Hooks in methods.

public
# init_query_vars( )

Init query vars by loading options.

Init query vars by loading options.

public
# get_errors( )

Get any errors from querystring

Get any errors from querystring

public
# add_endpoints( )

Add endpoints for query vars

Add endpoints for query vars

public array
# add_query_vars( array $vars )

add_query_vars function.

add_query_vars function.

Parameters

$vars
array
$vars

Returns

array
public array()
# get_query_vars( )

Get query vars

Get query vars

Returns

array()
public
# parse_request( )

Parse the request and look for query vars - endpoints may not be supported

Parse the request and look for query vars - endpoints may not be supported

public
# pre_get_posts( mixed $q )

Hook into pre_get_posts to do the main product query

Hook into pre_get_posts to do the main product query

Parameters

$q
mixed
$q query object
public string
# search_post_excerpt( string $where = '' )

search_post_excerpt function.

search_post_excerpt function.

Parameters

$where
string
$where (default: '')

Returns

string
(modified where clause)
public string
# exclude_protected_products( string $where )

Prevent password protected products appearing in the loops

Prevent password protected products appearing in the loops

Parameters

$where
string
$where

Returns

string
public string
# wpseo_metadesc( )

wpseo_metadesc function. Hooked into wpseo_ hook already, so no need for function_exist

wpseo_metadesc function. Hooked into wpseo_ hook already, so no need for function_exist

Returns

string
public string
# wpseo_metakey( )

wpseo_metakey function. Hooked into wpseo_ hook already, so no need for function_exist

wpseo_metakey function. Hooked into wpseo_ hook already, so no need for function_exist

Returns

string
public array
# the_posts( array $posts, WP_Query|boolean $query = false )

Hook into the_posts to do the main product query if needed - relevanssi compatibility

Hook into the_posts to do the main product query if needed - relevanssi compatibility

Parameters

$posts
array
$posts
$query
WP_Query|boolean
$query (default: false)

Returns

array
public
# product_query( mixed $q )

Query the products, applying sorting/ordering etc. This applies to the main wordpress loop

Query the products, applying sorting/ordering etc. This applies to the main wordpress loop

Parameters

$q
mixed
$q
public
# remove_product_query( )

Remove the query

Remove the query

public
# remove_ordering_args( )

Remove ordering queries

Remove ordering queries

public
# remove_posts_where( )

Remove the posts_where filter

Remove the posts_where filter

public
# get_products_in_view( )

Get an unpaginated list all product ID's (both filtered and unfiltered). Makes use of transients.

Get an unpaginated list all product ID's (both filtered and unfiltered). Makes use of transients.

public array
# get_catalog_ordering_args( mixed $orderby = '', mixed $order = '' )

Returns an array of arguments for ordering products based on the selected values

Returns an array of arguments for ordering products based on the selected values

Returns

array
public array
# order_by_popularity_post_clauses( array $args )

WP Core doens't let us change the sort direction for invidual orderby params - http://core.trac.wordpress.org/ticket/17065

WP Core doens't let us change the sort direction for invidual orderby params - http://core.trac.wordpress.org/ticket/17065

This lets us sort by meta value desc, and have a second orderby param.

Parameters

$args
array
$args

Returns

array
public array
# order_by_rating_post_clauses( array $args )

order_by_rating_post_clauses function.

order_by_rating_post_clauses function.

Parameters

$args
array
$args

Returns

array
public array
# get_meta_query( array $meta_query = array() )

Appends meta queries to an array.

Appends meta queries to an array.

Parameters

$meta_query
array
$meta_query

Returns

array
public array
# visibility_meta_query( string $compare = 'IN' )

Returns a meta query to handle product visibility

Returns a meta query to handle product visibility

Parameters

$compare
string
$compare (default: 'IN')

Returns

array
public array
# stock_status_meta_query( string $status = 'instock' )

Returns a meta query to handle product stock status

Returns a meta query to handle product stock status

Parameters

$status
string
$status (default: 'instock')

Returns

array
public
# layered_nav_init( )

Layered Nav Init

Layered Nav Init

public array
# layered_nav_query( array $filtered_posts )

Layered Nav post filter

Layered Nav post filter

Parameters

$filtered_posts
array
$filtered_posts

Returns

array
public
# price_filter_init( )

Price filter Init

Price filter Init

public array
# price_filter( array $filtered_posts )

Price Filter post filter

Price Filter post filter

Parameters

$filtered_posts
array
$filtered_posts

Returns

array

Magic methods summary

Properties summary

public array $query_vars
#

Public

array Query vars to add to wp
public array $unfiltered_product_ids
#

Public

array Unfiltered product ids (before layered nav etc)
public array $filtered_product_ids
#

Public

array Filtered product ids (after layered nav)
public array $filtered_product_ids_for_taxonomy
#

Public

array Filtered product ids (after layered nav, per taxonomy)
public array $post__in
#

Public

array Product IDs that match the layered nav + price filter
public string $meta_query
#

Public

array The meta query for the page
public array $layered_nav_post__in
#

Public

array Post IDs matching layered nav only
public array $layered_nav_product_ids
#

Public

array Stores post IDs matching layered nav, so price filter can find max price in view
WooCommerce API documentation generated by ApiGen 2.8.0