# woocommerce-pos/1.10.13/includes/API/V1/Traits/Query_Helpers.php

WCPOS – Point of Sale (POS) plugin for WooCommerce, version 1.10.13. 53 lines.

- Page: https://pluginprobe.com/plugins/woocommerce-pos/1.10.13/code/includes/API/V1/Traits/Query_Helpers.php
- Raw: https://pluginprobe.com/plugins/woocommerce-pos/1.10.13/raw/includes/API/V1/Traits/Query_Helpers.php
- Modified: 2026-08-25T07:52:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/woocommerce-pos/1.10.13/code/includes/API/V1/Traits/Query_Helpers.php#L10-L20`.

```php
<?php
/**
 * Query_Helpers.
 *
 * @package WCPOS\WooCommercePOS
 */

namespace WCPOS\WooCommercePOS\API\V1\Traits;

use WCPOS\WooCommercePOS\Logger;

trait Query_Helpers {
	/**
	 * Combine two meta_query arrays.
	 *
	 * @deprecated The only caller, Customers_Controller, now has its own private
	 *             wcpos_merge_meta_queries(). Kept because this trait is aliased as
	 *             public API in includes/API/class-aliases.php, so callers outside
	 *             this repository may still use it.
	 *
	 * @param array $meta_query1 First meta query array.
	 * @param array $meta_query2 Second meta query array.
	 *
	 * @return array Combined meta query array.
	 */
	public function wcpos_combine_meta_queries( $meta_query1, $meta_query2 ) {
		// If either meta_query is empty, return the other.
		if ( empty( $meta_query1 ) ) {
			return $meta_query2;
		}
		if ( empty( $meta_query2 ) ) {
			return $meta_query1;
		}

		// Check if both meta_queries have 'AND' as their top-level relation.
		if ( isset( $meta_query1['relation'] ) && 'AND' === $meta_query1['relation'] &&
		 isset( $meta_query2['relation'] ) && 'AND' === $meta_query2['relation'] ) {
			// Remove the 'relation' element and combine the arrays.
			unset( $meta_query1['relation'], $meta_query2['relation'] );
			$combined = array_merge( $meta_query1, $meta_query2 );
			array_unshift( $combined, array( 'relation' => 'AND' ) );
			return $combined;
		}

		// If both meta_queries are not empty and do not both have 'AND', combine them with 'AND' relation.
		return array(
			'relation' => 'AND',
			$meta_query1,
			$meta_query2,
		);
	}
}

```
