WC_Product_Data_Store_CPT::reviews_allowed_query_where()publicWC 3.2.0

Add ability to get products by 'reviews_allowed' in WC_Product_Query.

Method of the class: WC_Product_Data_Store_CPT{}

No Hooks.

Return

String.

Usage

$WC_Product_Data_Store_CPT = new WC_Product_Data_Store_CPT();
$WC_Product_Data_Store_CPT->reviews_allowed_query_where( $where, $wp_query );
$where(string) (required)
Where clause.
$wp_query(WP_Query) (required)
WP_Query instance.

Changelog

Since 3.2.0 Introduced.

WC_Product_Data_Store_CPT::reviews_allowed_query_where() code WC 9.4.2

public function reviews_allowed_query_where( $where, $wp_query ) {
	global $wpdb;

	if ( isset( $wp_query->query_vars['reviews_allowed'] ) && is_bool( $wp_query->query_vars['reviews_allowed'] ) ) {
		if ( $wp_query->query_vars['reviews_allowed'] ) {
			$where .= " AND $wpdb->posts.comment_status = 'open'";
		} else {
			$where .= " AND $wpdb->posts.comment_status = 'closed'";
		}
	}

	return $where;
}