本文整理汇总了PHP中Essential_Grid_Base::getVal方法的典型用法代码示例。如果您正苦于以下问题:PHP Essential_Grid_Base::getVal方法的具体用法?PHP Essential_Grid_Base::getVal怎么用?PHP Essential_Grid_Base::getVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Essential_Grid_Base
的用法示例。
在下文中一共展示了Essential_Grid_Base::getVal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_meta_query
/**
* 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;
}