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3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / class-wc-query.php
woocommerce / includes Last commit date
abstracts 7 years ago admin 7 years ago api 7 years ago cli 7 years ago customizer 7 years ago data-stores 7 years ago emails 7 years ago export 7 years ago gateways 7 years ago import 7 years ago interfaces 7 years ago legacy 7 years ago libraries 7 years ago log-handlers 7 years ago payment-tokens 7 years ago queue 7 years ago shipping 7 years ago shortcodes 7 years ago theme-support 7 years ago walkers 7 years ago widgets 7 years ago class-wc-ajax.php 7 years ago class-wc-api.php 7 years ago class-wc-auth.php 7 years ago class-wc-autoloader.php 7 years ago class-wc-background-emailer.php 7 years ago class-wc-background-updater.php 7 years ago class-wc-breadcrumb.php 7 years ago class-wc-cache-helper.php 7 years ago class-wc-cart-fees.php 7 years ago class-wc-cart-session.php 7 years ago class-wc-cart-totals.php 7 years ago class-wc-cart.php 7 years ago class-wc-checkout.php 7 years ago class-wc-cli.php 7 years ago class-wc-comments.php 7 years ago class-wc-countries.php 7 years ago class-wc-coupon.php 7 years ago class-wc-customer-download-log.php 7 years ago class-wc-customer-download.php 7 years ago class-wc-customer.php 7 years ago class-wc-data-exception.php 7 years ago class-wc-data-store.php 7 years ago class-wc-datetime.php 7 years ago class-wc-deprecated-action-hooks.php 7 years ago class-wc-deprecated-filter-hooks.php 7 years ago class-wc-discounts.php 7 years ago class-wc-download-handler.php 7 years ago class-wc-emails.php 7 years ago class-wc-embed.php 7 years ago class-wc-form-handler.php 7 years ago class-wc-frontend-scripts.php 7 years ago class-wc-geo-ip.php 7 years ago class-wc-geolite-integration.php 7 years ago class-wc-geolocation.php 7 years ago class-wc-https.php 7 years ago class-wc-install.php 7 years ago class-wc-integrations.php 7 years ago class-wc-log-levels.php 7 years ago class-wc-logger.php 7 years ago class-wc-meta-data.php 7 years ago class-wc-order-factory.php 7 years ago class-wc-order-item-coupon.php 7 years ago class-wc-order-item-fee.php 7 years ago class-wc-order-item-meta.php 7 years ago class-wc-order-item-product.php 7 years ago class-wc-order-item-shipping.php 7 years ago class-wc-order-item-tax.php 7 years ago class-wc-order-item.php 7 years ago class-wc-order-query.php 7 years ago class-wc-order-refund.php 7 years ago class-wc-order.php 7 years ago class-wc-payment-gateways.php 7 years ago class-wc-payment-tokens.php 7 years ago class-wc-post-data.php 7 years ago class-wc-post-types.php 7 years ago class-wc-privacy-background-process.php 7 years ago class-wc-privacy-erasers.php 7 years ago class-wc-privacy-exporters.php 7 years ago class-wc-privacy.php 7 years ago class-wc-product-attribute.php 7 years ago class-wc-product-download.php 7 years ago class-wc-product-external.php 7 years ago class-wc-product-factory.php 7 years ago class-wc-product-grouped.php 7 years ago class-wc-product-query.php 7 years ago class-wc-product-simple.php 7 years ago class-wc-product-variable.php 7 years ago class-wc-product-variation.php 7 years ago class-wc-query.php 7 years ago class-wc-regenerate-images-request.php 7 years ago class-wc-regenerate-images.php 7 years ago class-wc-register-wp-admin-settings.php 7 years ago class-wc-session-handler.php 7 years ago class-wc-shipping-rate.php 7 years ago class-wc-shipping-zone.php 7 years ago class-wc-shipping-zones.php 7 years ago class-wc-shipping.php 7 years ago class-wc-shortcodes.php 7 years ago class-wc-structured-data.php 7 years ago class-wc-tax.php 7 years ago class-wc-template-loader.php 7 years ago class-wc-tracker.php 7 years ago class-wc-validation.php 7 years ago class-wc-webhook.php 7 years ago class-woocommerce.php 7 years ago wc-account-functions.php 7 years ago wc-attribute-functions.php 7 years ago wc-cart-functions.php 7 years ago wc-conditional-functions.php 7 years ago wc-core-functions.php 7 years ago wc-coupon-functions.php 7 years ago wc-deprecated-functions.php 7 years ago wc-formatting-functions.php 7 years ago wc-notice-functions.php 7 years ago wc-order-functions.php 7 years ago wc-order-item-functions.php 7 years ago wc-page-functions.php 7 years ago wc-product-functions.php 7 years ago wc-rest-functions.php 7 years ago wc-stock-functions.php 7 years ago wc-template-functions.php 7 years ago wc-template-hooks.php 7 years ago wc-term-functions.php 7 years ago wc-update-functions.php 7 years ago wc-user-functions.php 7 years ago wc-webhook-functions.php 7 years ago wc-widget-functions.php 7 years ago
class-wc-query.php
898 lines
1 <?php
2 /**
3 * Contains the query functions for WooCommerce which alter the front-end post queries and loops
4 *
5 * @version 3.2.0
6 * @package WooCommerce\Classes
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * WC_Query Class.
13 */
14 class WC_Query {
15
16 /**
17 * Query vars to add to wp.
18 *
19 * @var array
20 */
21 public $query_vars = array();
22
23 /**
24 * Reference to the main product query on the page.
25 *
26 * @var array
27 */
28 private static $product_query;
29
30 /**
31 * Stores chosen attributes.
32 *
33 * @var array
34 */
35 private static $_chosen_attributes;
36
37 /**
38 * Constructor for the query class. Hooks in methods.
39 */
40 public function __construct() {
41 add_action( 'init', array( $this, 'add_endpoints' ) );
42 if ( ! is_admin() ) {
43 add_action( 'wp_loaded', array( $this, 'get_errors' ), 20 );
44 add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
45 add_action( 'parse_request', array( $this, 'parse_request' ), 0 );
46 add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
47 add_filter( 'the_posts', array( $this, 'remove_product_query_filters' ) );
48 add_filter( 'get_pagenum_link', array( $this, 'remove_add_to_cart_pagination' ), 10, 1 );
49 }
50 $this->init_query_vars();
51 }
52
53 /**
54 * Get any errors from querystring.
55 */
56 public function get_errors() {
57 $error = ! empty( $_GET['wc_error'] ) ? sanitize_text_field( wp_unslash( $_GET['wc_error'] ) ) : ''; // WPCS: input var ok, CSRF ok.
58
59 if ( $error && ! wc_has_notice( $error, 'error' ) ) {
60 wc_add_notice( $error, 'error' );
61 }
62 }
63
64 /**
65 * Init query vars by loading options.
66 */
67 public function init_query_vars() {
68 // Query vars to add to WP.
69 $this->query_vars = array(
70 // Checkout actions.
71 'order-pay' => get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' ),
72 'order-received' => get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' ),
73 // My account actions.
74 'orders' => get_option( 'woocommerce_myaccount_orders_endpoint', 'orders' ),
75 'view-order' => get_option( 'woocommerce_myaccount_view_order_endpoint', 'view-order' ),
76 'downloads' => get_option( 'woocommerce_myaccount_downloads_endpoint', 'downloads' ),
77 'edit-account' => get_option( 'woocommerce_myaccount_edit_account_endpoint', 'edit-account' ),
78 'edit-address' => get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ),
79 'payment-methods' => get_option( 'woocommerce_myaccount_payment_methods_endpoint', 'payment-methods' ),
80 'lost-password' => get_option( 'woocommerce_myaccount_lost_password_endpoint', 'lost-password' ),
81 'customer-logout' => get_option( 'woocommerce_logout_endpoint', 'customer-logout' ),
82 'add-payment-method' => get_option( 'woocommerce_myaccount_add_payment_method_endpoint', 'add-payment-method' ),
83 'delete-payment-method' => get_option( 'woocommerce_myaccount_delete_payment_method_endpoint', 'delete-payment-method' ),
84 'set-default-payment-method' => get_option( 'woocommerce_myaccount_set_default_payment_method_endpoint', 'set-default-payment-method' ),
85 );
86 }
87
88 /**
89 * Get page title for an endpoint.
90 *
91 * @param string $endpoint Endpoint key.
92 * @return string
93 */
94 public function get_endpoint_title( $endpoint ) {
95 global $wp;
96
97 switch ( $endpoint ) {
98 case 'order-pay':
99 $title = __( 'Pay for order', 'woocommerce' );
100 break;
101 case 'order-received':
102 $title = __( 'Order received', 'woocommerce' );
103 break;
104 case 'orders':
105 if ( ! empty( $wp->query_vars['orders'] ) ) {
106 /* translators: %s: page */
107 $title = sprintf( __( 'Orders (page %d)', 'woocommerce' ), intval( $wp->query_vars['orders'] ) );
108 } else {
109 $title = __( 'Orders', 'woocommerce' );
110 }
111 break;
112 case 'view-order':
113 $order = wc_get_order( $wp->query_vars['view-order'] );
114 /* translators: %s: order number */
115 $title = ( $order ) ? sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ) : '';
116 break;
117 case 'downloads':
118 $title = __( 'Downloads', 'woocommerce' );
119 break;
120 case 'edit-account':
121 $title = __( 'Account details', 'woocommerce' );
122 break;
123 case 'edit-address':
124 $title = __( 'Addresses', 'woocommerce' );
125 break;
126 case 'payment-methods':
127 $title = __( 'Payment methods', 'woocommerce' );
128 break;
129 case 'add-payment-method':
130 $title = __( 'Add payment method', 'woocommerce' );
131 break;
132 case 'lost-password':
133 $title = __( 'Lost password', 'woocommerce' );
134 break;
135 default:
136 $title = '';
137 break;
138 }
139
140 return apply_filters( 'woocommerce_endpoint_' . $endpoint . '_title', $title, $endpoint );
141 }
142
143 /**
144 * Endpoint mask describing the places the endpoint should be added.
145 *
146 * @since 2.6.2
147 * @return int
148 */
149 public function get_endpoints_mask() {
150 if ( 'page' === get_option( 'show_on_front' ) ) {
151 $page_on_front = get_option( 'page_on_front' );
152 $myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' );
153 $checkout_page_id = get_option( 'woocommerce_checkout_page_id' );
154
155 if ( in_array( $page_on_front, array( $myaccount_page_id, $checkout_page_id ), true ) ) {
156 return EP_ROOT | EP_PAGES;
157 }
158 }
159
160 return EP_PAGES;
161 }
162
163 /**
164 * Add endpoints for query vars.
165 */
166 public function add_endpoints() {
167 $mask = $this->get_endpoints_mask();
168
169 foreach ( $this->get_query_vars() as $key => $var ) {
170 if ( ! empty( $var ) ) {
171 add_rewrite_endpoint( $var, $mask );
172 }
173 }
174 }
175
176 /**
177 * Add query vars.
178 *
179 * @param array $vars Query vars.
180 * @return array
181 */
182 public function add_query_vars( $vars ) {
183 foreach ( $this->get_query_vars() as $key => $var ) {
184 $vars[] = $key;
185 }
186 return $vars;
187 }
188
189 /**
190 * Get query vars.
191 *
192 * @return array
193 */
194 public function get_query_vars() {
195 return apply_filters( 'woocommerce_get_query_vars', $this->query_vars );
196 }
197
198 /**
199 * Get query current active query var.
200 *
201 * @return string
202 */
203 public function get_current_endpoint() {
204 global $wp;
205
206 foreach ( $this->get_query_vars() as $key => $value ) {
207 if ( isset( $wp->query_vars[ $key ] ) ) {
208 return $key;
209 }
210 }
211 return '';
212 }
213
214 /**
215 * Parse the request and look for query vars - endpoints may not be supported.
216 */
217 public function parse_request() {
218 global $wp;
219
220 // Map query vars to their keys, or get them if endpoints are not supported.
221 foreach ( $this->get_query_vars() as $key => $var ) {
222 if ( isset( $_GET[ $var ] ) ) { // WPCS: input var ok, CSRF ok.
223 $wp->query_vars[ $key ] = sanitize_text_field( wp_unslash( $_GET[ $var ] ) ); // WPCS: input var ok, CSRF ok.
224 } elseif ( isset( $wp->query_vars[ $var ] ) ) {
225 $wp->query_vars[ $key ] = $wp->query_vars[ $var ];
226 }
227 }
228 }
229
230 /**
231 * Are we currently on the front page?
232 *
233 * @param WP_Query $q Query instance.
234 * @return bool
235 */
236 private function is_showing_page_on_front( $q ) {
237 return $q->is_home() && 'page' === get_option( 'show_on_front' );
238 }
239
240 /**
241 * Is the front page a page we define?
242 *
243 * @param int $page_id Page ID.
244 * @return bool
245 */
246 private function page_on_front_is( $page_id ) {
247 return absint( get_option( 'page_on_front' ) ) === absint( $page_id );
248 }
249
250 /**
251 * Hook into pre_get_posts to do the main product query.
252 *
253 * @param WP_Query $q Query instance.
254 */
255 public function pre_get_posts( $q ) {
256 // We only want to affect the main query.
257 if ( ! $q->is_main_query() ) {
258 return;
259 }
260
261 // Fix for endpoints on the homepage.
262 if ( $this->is_showing_page_on_front( $q ) && ! $this->page_on_front_is( $q->get( 'page_id' ) ) ) {
263 $_query = wp_parse_args( $q->query );
264 if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->get_query_vars() ) ) ) {
265 $q->is_page = true;
266 $q->is_home = false;
267 $q->is_singular = true;
268 $q->set( 'page_id', (int) get_option( 'page_on_front' ) );
269 add_filter( 'redirect_canonical', '__return_false' );
270 }
271 }
272
273 // When orderby is set, WordPress shows posts on the front-page. Get around that here.
274 if ( $this->is_showing_page_on_front( $q ) && $this->page_on_front_is( wc_get_page_id( 'shop' ) ) ) {
275 $_query = wp_parse_args( $q->query );
276 if ( empty( $_query ) || ! array_diff( array_keys( $_query ), array( 'preview', 'page', 'paged', 'cpage', 'orderby' ) ) ) {
277 $q->set( 'page_id', (int) get_option( 'page_on_front' ) );
278 $q->is_page = true;
279 $q->is_home = false;
280
281 // WP supporting themes show post type archive.
282 if ( current_theme_supports( 'woocommerce' ) ) {
283 $q->set( 'post_type', 'product' );
284 } else {
285 $q->is_singular = true;
286 }
287 }
288 }
289
290 // Fix product feeds.
291 if ( $q->is_feed() && $q->is_post_type_archive( 'product' ) ) {
292 $q->is_comment_feed = false;
293 }
294
295 // Special check for shops with the PRODUCT POST TYPE ARCHIVE on front.
296 if ( current_theme_supports( 'woocommerce' ) && $q->is_page() && 'page' === get_option( 'show_on_front' ) && absint( $q->get( 'page_id' ) ) === wc_get_page_id( 'shop' ) ) {
297 // This is a front-page shop.
298 $q->set( 'post_type', 'product' );
299 $q->set( 'page_id', '' );
300
301 if ( isset( $q->query['paged'] ) ) {
302 $q->set( 'paged', $q->query['paged'] );
303 }
304
305 // Define a variable so we know this is the front page shop later on.
306 wc_maybe_define_constant( 'SHOP_IS_ON_FRONT', true );
307
308 // Get the actual WP page to avoid errors and let us use is_front_page().
309 // This is hacky but works. Awaiting https://core.trac.wordpress.org/ticket/21096.
310 global $wp_post_types;
311
312 $shop_page = get_post( wc_get_page_id( 'shop' ) );
313
314 $wp_post_types['product']->ID = $shop_page->ID;
315 $wp_post_types['product']->post_title = $shop_page->post_title;
316 $wp_post_types['product']->post_name = $shop_page->post_name;
317 $wp_post_types['product']->post_type = $shop_page->post_type;
318 $wp_post_types['product']->ancestors = get_ancestors( $shop_page->ID, $shop_page->post_type );
319
320 // Fix conditional Functions like is_front_page.
321 $q->is_singular = false;
322 $q->is_post_type_archive = true;
323 $q->is_archive = true;
324 $q->is_page = true;
325
326 // Remove post type archive name from front page title tag.
327 add_filter( 'post_type_archive_title', '__return_empty_string', 5 );
328
329 // Fix WP SEO.
330 if ( class_exists( 'WPSEO_Meta' ) ) {
331 add_filter( 'wpseo_metadesc', array( $this, 'wpseo_metadesc' ) );
332 add_filter( 'wpseo_metakey', array( $this, 'wpseo_metakey' ) );
333 }
334 } elseif ( ! $q->is_post_type_archive( 'product' ) && ! $q->is_tax( get_object_taxonomies( 'product' ) ) ) {
335 // Only apply to product categories, the product post archive, the shop page, product tags, and product attribute taxonomies.
336 return;
337 }
338
339 $this->product_query( $q );
340 }
341
342 /**
343 * Pre_get_posts above may adjust the main query to add WooCommerce logic. When this query is done, we need to ensure
344 * all custom filters are removed.
345 *
346 * This is done here during the_posts filter. The input is not changed.
347 *
348 * @param array $posts Posts from WP Query.
349 * @return array
350 */
351 public function remove_product_query_filters( $posts ) {
352 $this->remove_ordering_args();
353 return $posts;
354 }
355
356 /**
357 * WP SEO meta description.
358 *
359 * Hooked into wpseo_ hook already, so no need for function_exist.
360 *
361 * @return string
362 */
363 public function wpseo_metadesc() {
364 return WPSEO_Meta::get_value( 'metadesc', wc_get_page_id( 'shop' ) );
365 }
366
367 /**
368 * WP SEO meta key.
369 *
370 * Hooked into wpseo_ hook already, so no need for function_exist.
371 *
372 * @return string
373 */
374 public function wpseo_metakey() {
375 return WPSEO_Meta::get_value( 'metakey', wc_get_page_id( 'shop' ) );
376 }
377
378 /**
379 * Query the products, applying sorting/ordering etc.
380 * This applies to the main WordPress loop.
381 *
382 * @param WP_Query $q Query instance.
383 */
384 public function product_query( $q ) {
385 if ( ! is_feed() ) {
386 $ordering = $this->get_catalog_ordering_args();
387 $q->set( 'orderby', $ordering['orderby'] );
388 $q->set( 'order', $ordering['order'] );
389
390 if ( isset( $ordering['meta_key'] ) ) {
391 $q->set( 'meta_key', $ordering['meta_key'] );
392 }
393 }
394
395 // Query vars that affect posts shown.
396 $q->set( 'meta_query', $this->get_meta_query( $q->get( 'meta_query' ), true ) );
397 $q->set( 'tax_query', $this->get_tax_query( $q->get( 'tax_query' ), true ) );
398 $q->set( 'wc_query', 'product_query' );
399 $q->set( 'post__in', array_unique( (array) apply_filters( 'loop_shop_post_in', array() ) ) );
400
401 // Work out how many products to query.
402 $q->set( 'posts_per_page', $q->get( 'posts_per_page' ) ? $q->get( 'posts_per_page' ) : apply_filters( 'loop_shop_per_page', wc_get_default_products_per_row() * wc_get_default_product_rows_per_page() ) );
403
404 // Store reference to this query.
405 self::$product_query = $q;
406
407 do_action( 'woocommerce_product_query', $q, $this );
408 }
409
410 /**
411 * Remove the query.
412 */
413 public function remove_product_query() {
414 remove_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
415 }
416
417 /**
418 * Remove ordering queries.
419 */
420 public function remove_ordering_args() {
421 remove_filter( 'posts_clauses', array( $this, 'order_by_price_asc_post_clauses' ) );
422 remove_filter( 'posts_clauses', array( $this, 'order_by_price_desc_post_clauses' ) );
423 remove_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) );
424 remove_filter( 'posts_clauses', array( $this, 'order_by_rating_post_clauses' ) );
425 }
426
427 /**
428 * Returns an array of arguments for ordering products based on the selected values.
429 *
430 * @param string $orderby Order by param.
431 * @param string $order Order param.
432 * @return array
433 */
434 public function get_catalog_ordering_args( $orderby = '', $order = '' ) {
435 // Get ordering from query string unless defined.
436 if ( ! $orderby ) {
437 $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( (string) wp_unslash( $_GET['orderby'] ) ) : wc_clean( get_query_var( 'orderby' ) ); // WPCS: sanitization ok, input var ok, CSRF ok.
438
439 if ( ! $orderby_value ) {
440 if ( is_search() ) {
441 $orderby_value = 'relevance';
442 } else {
443 $orderby_value = apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby', 'menu_order' ) );
444 }
445 }
446
447 // Get order + orderby args from string.
448 $orderby_value = explode( '-', $orderby_value );
449 $orderby = esc_attr( $orderby_value[0] );
450 $order = ! empty( $orderby_value[1] ) ? $orderby_value[1] : $order;
451 }
452
453 $orderby = strtolower( $orderby );
454 $order = strtoupper( $order );
455 $args = array(
456 'orderby' => $orderby,
457 'order' => ( 'DESC' === $order ) ? 'DESC' : 'ASC',
458 'meta_key' => '', // @codingStandardsIgnoreLine
459 );
460
461 switch ( $orderby ) {
462 case 'id':
463 $args['orderby'] = 'ID';
464 break;
465 case 'menu_order':
466 $args['orderby'] = 'menu_order title';
467 break;
468 case 'title':
469 $args['orderby'] = 'title';
470 $args['order'] = ( 'DESC' === $order ) ? 'DESC' : 'ASC';
471 break;
472 case 'relevance':
473 $args['orderby'] = 'relevance';
474 $args['order'] = 'DESC';
475 break;
476 case 'rand':
477 $args['orderby'] = 'rand'; // @codingStandardsIgnoreLine
478 break;
479 case 'date':
480 $args['orderby'] = 'date ID';
481 $args['order'] = ( 'ASC' === $order ) ? 'ASC' : 'DESC';
482 break;
483 case 'price':
484 if ( 'DESC' === $order ) {
485 add_filter( 'posts_clauses', array( $this, 'order_by_price_desc_post_clauses' ) );
486 } else {
487 add_filter( 'posts_clauses', array( $this, 'order_by_price_asc_post_clauses' ) );
488 }
489 break;
490 case 'popularity':
491 $args['meta_key'] = 'total_sales'; // @codingStandardsIgnoreLine
492
493 // Sorting handled later though a hook.
494 add_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) );
495 break;
496 case 'rating':
497 $args['meta_key'] = '_wc_average_rating'; // @codingStandardsIgnoreLine
498 $args['orderby'] = array(
499 'meta_value_num' => 'DESC',
500 'ID' => 'ASC',
501 );
502 break;
503 }
504
505 return apply_filters( 'woocommerce_get_catalog_ordering_args', $args );
506 }
507
508 /**
509 * Handle numeric price sorting.
510 *
511 * @param array $args Query args.
512 * @return array
513 */
514 public function order_by_price_asc_post_clauses( $args ) {
515 global $wpdb, $wp_query;
516
517 if ( isset( $wp_query->queried_object, $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy ) && is_a( $wp_query->queried_object, 'WP_Term' ) ) {
518 $search_within_terms = get_terms( array(
519 'taxonomy' => $wp_query->queried_object->taxonomy,
520 'child_of' => $wp_query->queried_object->term_id,
521 'fields' => 'tt_ids',
522 ) );
523 $search_within_terms[] = $wp_query->queried_object->term_taxonomy_id;
524 $args['join'] .= " INNER JOIN (
525 SELECT post_id, min( meta_value+0 ) price
526 FROM $wpdb->postmeta
527 INNER JOIN (
528 SELECT $wpdb->term_relationships.object_id
529 FROM $wpdb->term_relationships
530 WHERE 1=1
531 AND $wpdb->term_relationships.term_taxonomy_id IN (" . implode( ',', array_map( 'absint', $search_within_terms ) ) . ")
532 ) as products_within_terms ON $wpdb->postmeta.post_id = products_within_terms.object_id
533 WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id ";
534 } else {
535 $args['join'] .= " INNER JOIN ( SELECT post_id, min( meta_value+0 ) price FROM $wpdb->postmeta WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id ";
536 }
537 $args['orderby'] = " price_query.price ASC, $wpdb->posts.ID ASC ";
538 return $args;
539 }
540
541 /**
542 * Handle numeric price sorting.
543 *
544 * @param array $args Query args.
545 * @return array
546 */
547 public function order_by_price_desc_post_clauses( $args ) {
548 global $wpdb, $wp_query;
549
550 if ( isset( $wp_query->queried_object, $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy ) && is_a( $wp_query->queried_object, 'WP_Term' ) ) {
551 $search_within_terms = get_terms( array(
552 'taxonomy' => $wp_query->queried_object->taxonomy,
553 'child_of' => $wp_query->queried_object->term_id,
554 'fields' => 'tt_ids',
555 ) );
556 $search_within_terms[] = $wp_query->queried_object->term_taxonomy_id;
557 $args['join'] .= " INNER JOIN (
558 SELECT post_id, max( meta_value+0 ) price
559 FROM $wpdb->postmeta
560 INNER JOIN (
561 SELECT $wpdb->term_relationships.object_id
562 FROM $wpdb->term_relationships
563 WHERE 1=1
564 AND $wpdb->term_relationships.term_taxonomy_id IN (" . implode( ',', array_map( 'absint', $search_within_terms ) ) . ")
565 ) as products_within_terms ON $wpdb->postmeta.post_id = products_within_terms.object_id
566 WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id ";
567 } else {
568 $args['join'] .= " INNER JOIN ( SELECT post_id, max( meta_value+0 ) price FROM $wpdb->postmeta WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id ";
569 }
570
571 $args['orderby'] = " price_query.price DESC, $wpdb->posts.ID DESC ";
572 return $args;
573 }
574
575 /**
576 * WP Core doens't let us change the sort direction for individual orderby params - https://core.trac.wordpress.org/ticket/17065.
577 *
578 * This lets us sort by meta value desc, and have a second orderby param.
579 *
580 * @param array $args Query args.
581 * @return array
582 */
583 public function order_by_popularity_post_clauses( $args ) {
584 global $wpdb;
585 $args['orderby'] = "$wpdb->postmeta.meta_value+0 DESC, $wpdb->posts.post_date DESC";
586 return $args;
587 }
588
589 /**
590 * Appends meta queries to an array.
591 *
592 * @param array $meta_query Meta query.
593 * @param bool $main_query If is main query.
594 * @return array
595 */
596 public function get_meta_query( $meta_query = array(), $main_query = false ) {
597 if ( ! is_array( $meta_query ) ) {
598 $meta_query = array();
599 }
600 $meta_query['price_filter'] = $this->price_filter_meta_query();
601 return array_filter( apply_filters( 'woocommerce_product_query_meta_query', $meta_query, $this ) );
602 }
603
604 /**
605 * Appends tax queries to an array.
606 *
607 * @param array $tax_query Tax query.
608 * @param bool $main_query If is main query.
609 * @return array
610 */
611 public function get_tax_query( $tax_query = array(), $main_query = false ) {
612 if ( ! is_array( $tax_query ) ) {
613 $tax_query = array(
614 'relation' => 'AND',
615 );
616 }
617
618 // Layered nav filters on terms.
619 if ( $main_query ) {
620 foreach ( $this->get_layered_nav_chosen_attributes() as $taxonomy => $data ) {
621 $tax_query[] = array(
622 'taxonomy' => $taxonomy,
623 'field' => 'slug',
624 'terms' => $data['terms'],
625 'operator' => 'and' === $data['query_type'] ? 'AND' : 'IN',
626 'include_children' => false,
627 );
628 }
629 }
630
631 $product_visibility_terms = wc_get_product_visibility_term_ids();
632 $product_visibility_not_in = array( is_search() && $main_query ? $product_visibility_terms['exclude-from-search'] : $product_visibility_terms['exclude-from-catalog'] );
633
634 // Hide out of stock products.
635 if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
636 $product_visibility_not_in[] = $product_visibility_terms['outofstock'];
637 }
638
639 // Filter by rating.
640 if ( isset( $_GET['rating_filter'] ) ) { // WPCS: input var ok, CSRF ok.
641 $rating_filter = array_filter( array_map( 'absint', explode( ',', $_GET['rating_filter'] ) ) ); // WPCS: input var ok, CSRF ok, Sanitization ok.
642 $rating_terms = array();
643 for ( $i = 1; $i <= 5; $i ++ ) {
644 if ( in_array( $i, $rating_filter, true ) && isset( $product_visibility_terms[ 'rated-' . $i ] ) ) {
645 $rating_terms[] = $product_visibility_terms[ 'rated-' . $i ];
646 }
647 }
648 if ( ! empty( $rating_terms ) ) {
649 $tax_query[] = array(
650 'taxonomy' => 'product_visibility',
651 'field' => 'term_taxonomy_id',
652 'terms' => $rating_terms,
653 'operator' => 'IN',
654 'rating_filter' => true,
655 );
656 }
657 }
658
659 if ( ! empty( $product_visibility_not_in ) ) {
660 $tax_query[] = array(
661 'taxonomy' => 'product_visibility',
662 'field' => 'term_taxonomy_id',
663 'terms' => $product_visibility_not_in,
664 'operator' => 'NOT IN',
665 );
666 }
667
668 return array_filter( apply_filters( 'woocommerce_product_query_tax_query', $tax_query, $this ) );
669 }
670
671 /**
672 * Return a meta query for filtering by price.
673 *
674 * @return array
675 */
676 private function price_filter_meta_query() {
677 if ( isset( $_GET['max_price'] ) || isset( $_GET['min_price'] ) ) { // WPCS: input var ok, CSRF ok.
678 $meta_query = wc_get_min_max_price_meta_query( $_GET ); // WPCS: input var ok, CSRF ok.
679 $meta_query['price_filter'] = true;
680
681 return $meta_query;
682 }
683
684 return array();
685 }
686
687 /**
688 * Get the main query which product queries ran against.
689 *
690 * @return array
691 */
692 public static function get_main_query() {
693 return self::$product_query;
694 }
695
696 /**
697 * Get the tax query which was used by the main query.
698 *
699 * @return array
700 */
701 public static function get_main_tax_query() {
702 $tax_query = isset( self::$product_query->tax_query, self::$product_query->tax_query->queries ) ? self::$product_query->tax_query->queries : array();
703
704 return $tax_query;
705 }
706
707 /**
708 * Get the meta query which was used by the main query.
709 *
710 * @return array
711 */
712 public static function get_main_meta_query() {
713 $args = self::$product_query->query_vars;
714 $meta_query = isset( $args['meta_query'] ) ? $args['meta_query'] : array();
715
716 return $meta_query;
717 }
718
719 /**
720 * Based on WP_Query::parse_search
721 */
722 public static function get_main_search_query_sql() {
723 global $wpdb;
724
725 $args = self::$product_query->query_vars;
726 $search_terms = isset( $args['search_terms'] ) ? $args['search_terms'] : array();
727 $sql = array();
728
729 foreach ( $search_terms as $term ) {
730 // Terms prefixed with '-' should be excluded.
731 $include = '-' !== substr( $term, 0, 1 );
732
733 if ( $include ) {
734 $like_op = 'LIKE';
735 $andor_op = 'OR';
736 } else {
737 $like_op = 'NOT LIKE';
738 $andor_op = 'AND';
739 $term = substr( $term, 1 );
740 }
741
742 $like = '%' . $wpdb->esc_like( $term ) . '%';
743 $sql[] = $wpdb->prepare( "(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_excerpt $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s))", $like, $like, $like ); // unprepared SQL ok.
744 }
745
746 if ( ! empty( $sql ) && ! is_user_logged_in() ) {
747 $sql[] = "($wpdb->posts.post_password = '')";
748 }
749
750 return implode( ' AND ', $sql );
751 }
752
753 /**
754 * Get an array of attributes and terms selected with the layered nav widget.
755 *
756 * @return array
757 */
758 public static function get_layered_nav_chosen_attributes() {
759 if ( ! is_array( self::$_chosen_attributes ) ) {
760 self::$_chosen_attributes = array();
761
762 if ( ! empty( $_GET ) ) { // WPCS: input var ok, CSRF ok.
763 foreach ( $_GET as $key => $value ) { // WPCS: input var ok, CSRF ok.
764 if ( 0 === strpos( $key, 'filter_' ) ) {
765 $attribute = wc_sanitize_taxonomy_name( str_replace( 'filter_', '', $key ) );
766 $taxonomy = wc_attribute_taxonomy_name( $attribute );
767 $filter_terms = ! empty( $value ) ? explode( ',', wc_clean( wp_unslash( $value ) ) ) : array();
768
769 if ( empty( $filter_terms ) || ! taxonomy_exists( $taxonomy ) || ! wc_attribute_taxonomy_id_by_name( $attribute ) ) {
770 continue;
771 }
772
773 $query_type = ! empty( $_GET[ 'query_type_' . $attribute ] ) && in_array( $_GET[ 'query_type_' . $attribute ], array( 'and', 'or' ), true ) ? wc_clean( wp_unslash( $_GET[ 'query_type_' . $attribute ] ) ) : ''; // WPCS: sanitization ok, input var ok, CSRF ok.
774 self::$_chosen_attributes[ $taxonomy ]['terms'] = array_map( 'sanitize_title', $filter_terms ); // Ensures correct encoding.
775 self::$_chosen_attributes[ $taxonomy ]['query_type'] = $query_type ? $query_type : apply_filters( 'woocommerce_layered_nav_default_query_type', 'and' );
776 }
777 }
778 }
779 }
780 return self::$_chosen_attributes;
781 }
782
783 /**
784 * Remove the add-to-cart param from pagination urls.
785 *
786 * @param string $url URL.
787 * @return string
788 */
789 public function remove_add_to_cart_pagination( $url ) {
790 return remove_query_arg( 'add-to-cart', $url );
791 }
792
793 // @codingStandardsIgnoreStart
794 /**
795 * Order by rating post clauses.
796 *
797 * @deprecated 3.0.0
798 * @param array $args
799 * @return array
800 */
801 public function order_by_rating_post_clauses( $args ) {
802 global $wpdb;
803
804 wc_deprecated_function( 'order_by_rating_post_clauses', '3.0' );
805
806 $args['fields'] .= ", AVG( $wpdb->commentmeta.meta_value ) as average_rating ";
807 $args['where'] .= " AND ( $wpdb->commentmeta.meta_key = 'rating' OR $wpdb->commentmeta.meta_key IS null ) ";
808 $args['join'] .= "
809 LEFT OUTER JOIN $wpdb->comments ON($wpdb->posts.ID = $wpdb->comments.comment_post_ID)
810 LEFT JOIN $wpdb->commentmeta ON($wpdb->comments.comment_ID = $wpdb->commentmeta.comment_id)
811 ";
812 $args['orderby'] = "average_rating DESC, $wpdb->posts.post_date DESC";
813 $args['groupby'] = "$wpdb->posts.ID";
814
815 return $args;
816 }
817
818 /**
819 * Return a meta query for filtering by rating.
820 *
821 * @deprecated 3.0.0 Replaced with taxonomy.
822 * @return array
823 */
824 public function rating_filter_meta_query() {
825 return array();
826 }
827
828 /**
829 * Returns a meta query to handle product visibility.
830 *
831 * @deprecated 3.0.0 Replaced with taxonomy.
832 * @param string $compare (default: 'IN')
833 * @return array
834 */
835 public function visibility_meta_query( $compare = 'IN' ) {
836 return array();
837 }
838
839 /**
840 * Returns a meta query to handle product stock status.
841 *
842 * @deprecated 3.0.0 Replaced with taxonomy.
843 * @param string $status (default: 'instock')
844 * @return array
845 */
846 public function stock_status_meta_query( $status = 'instock' ) {
847 return array();
848 }
849
850 /**
851 * Layered nav init.
852 *
853 * @deprecated 2.6.0
854 */
855 public function layered_nav_init() {
856 wc_deprecated_function( 'layered_nav_init', '2.6' );
857 }
858
859 /**
860 * Get an unpaginated list all product IDs (both filtered and unfiltered). Makes use of transients.
861 *
862 * @deprecated 2.6.0 due to performance concerns
863 */
864 public function get_products_in_view() {
865 wc_deprecated_function( 'get_products_in_view', '2.6' );
866 }
867
868 /**
869 * Layered Nav post filter.
870 *
871 * @deprecated 2.6.0 due to performance concerns
872 *
873 * @param mixed $deprecated Deprecated.
874 */
875 public function layered_nav_query( $deprecated ) {
876 wc_deprecated_function( 'layered_nav_query', '2.6' );
877 }
878
879 /**
880 * Search post excerpt.
881 *
882 * @deprecated 3.2.0 - Not needed anymore since WordPress 4.5.
883 */
884 public function search_post_excerpt( $where = '' ) {
885 wc_deprecated_function( 'WC_Query::search_post_excerpt', '3.2.0', 'Excerpt added to search query by default since WordPress 4.5.' );
886 return $where;
887 }
888
889 /**
890 * Remove the posts_where filter.
891 * @deprecated 3.2.0 - Nothing to remove anymore because search_post_excerpt() is deprecated.
892 */
893 public function remove_posts_where() {
894 wc_deprecated_function( 'WC_Query::remove_posts_where', '3.2.0', 'Nothing to remove anymore because search_post_excerpt() is deprecated.' );
895 }
896 // @codingStandardsIgnoreEnd
897 }
898