/** * get meta query for filtering woocommerce posts. */ public static function get_meta_query($args) { $base = new Essential_Grid_Base(); $regPriceFrom = $base->getVal($args, self::ARG_REGULAR_PRICE_FROM); $regPriceTo = $base->getVal($args, self::ARG_REGULAR_PRICE_TO); $salePriceFrom = $base->getVal($args, self::ARG_SALE_PRICE_FROM); $salePriceTo = $base->getVal($args, self::ARG_SALE_PRICE_TO); $inStockOnly = $base->getVal($args, self::ARG_IN_STOCK_ONLY); $featuredOnly = $base->getVal($args, self::ARG_FEATURED_ONLY); $arrQueries = array(); //get regular price array if (!empty($regPriceFrom) || !empty($regPriceTo)) { $arrQueries[] = self::get_price_query($regPriceFrom, $regPriceTo, self::META_REGULAR_PRICE); } //get sale price array if (!empty($salePriceFrom) || !empty($salePriceTo)) { $arrQueries[] = self::get_price_query($salePriceFrom, $salePriceTo, self::META_SALE_PRICE); } if ($inStockOnly == 'true') { $query = array('key' => self::META_STOCK_STATUS, 'value' => 'instock'); $arrQueries[] = $query; } if ($featuredOnly == 'true') { $query = array('key' => self::META_FEATURED, 'value' => 'yes'); $arrQueries[] = $query; } $query = array(); if (!empty($arrQueries)) { $query = array('meta_query' => $arrQueries); } return $query; }