示例#1
0
文件: adopt.php 项目: slavic18/cats
										<div class="cat-name"><a href="#" title=""></a></div>
										<p></p>
									</div>
								</div>
							</div>
						</div>
					</div>

					<!-- Cat Thumb Carousel display -->
					<div class="tabbys-cat-product-slider">
						<div id="tabbys-cat-product-slider" class="owl-carousel">
							<?php 
    while ($catsQuery->have_posts()) {
        $catsQuery->the_post();
        $articleObj = Article_Object::init();
        echo Fruitframe_Renderer::render_template_part('single-mobile-product', '', ['post' => $articleObj->getPostObject(), 'type' => 'adopt']);
    }
    ?>
						</div>
						<div class="owl-controls">
							<div class="owl-buttons">
								<div class="owl-prev custom-prev"></div>
								<div class="owl-next custom-next"></div>
							</div>
						</div>
					</div>
				</div>
				<div class="tabby-loader"></div>
			</div>
		</div>
	<?php 
示例#2
0
文件: request.php 项目: slavic18/cats
 public function getProductsAction()
 {
     try {
         if (!isset($_POST['filters'])) {
             throw new Exception('Not have come data make a quick search.');
         }
         $filters = $_POST['filters'];
         $params = explode(',', $filters);
         $updatedParams = [];
         foreach ($params as $k => $param) {
             if ($k % 2) {
                 $key = $params[$k - 1];
                 if (is_array($updatedParams[$key])) {
                     $updatedParams[$key][] = $param;
                 } else {
                     $updatedParams[$key] = $param;
                 }
             } else {
                 if (!isset($updatedParams[$param])) {
                     $updatedParams[$param] = $param;
                 } else {
                     $updatedParams[$param] = (array) $updatedParams[$param];
                 }
             }
         }
         $offset = $_POST['offset'];
         $args = ['post_type' => 'product', 'posts_per_page' => 15 + $offset, 'orderby' => 'title', 'order' => 'ASC'];
         $meta = ['relation' => 'AND'];
         foreach ($updatedParams as $key => $filter) {
             unset($oneMeta);
             switch ($key) {
                 case 'personality':
                 case 'cat_marking':
                 case 'cat_color':
                 case 'gender':
                 case 'special_needs':
                 case 'breed':
                     $oneMeta = ['key' => $key, 'value' => $filter, 'compare' => is_array($filter) ? 'in' : '='];
                     break;
                 case 'age':
                     if (is_array($filter)) {
                         $filter = max($filter);
                         $oneMeta = ['key' => 'calculated_age', 'value' => $filter, 'compare' => '<='];
                     } else {
                         $oneMeta = ['key' => 'calculated_age', 'value' => $filter, 'compare' => '<='];
                     }
                     break;
                 case 'order':
                     if ($filter == 'oldest') {
                         $args['order'] = 'DESC';
                     } else {
                         $args['order'] = 'ASC';
                     }
                     break;
                 case 'favorites':
                     if (isset($_COOKIE["favourites"])) {
                         $args['post__in'] = explode(',', $_COOKIE["favourites"]);
                     }
                     break;
                 default:
                     break;
             }
             if (isset($oneMeta)) {
                 $meta[] = $oneMeta;
             }
         }
         $type = 'sponsor';
         if (isset($_POST['type']) && $_POST['type'] == 'adopt') {
             $type = 'adopt';
             $meta[] = ['key' => 'can_be_adopted', 'value' => 1, 'compare' => '='];
         }
         $meta[] = ['key' => 'is_service', 'compare' => 'NOT EXISTS'];
         $args['meta_query'] = $meta;
         $products = get_posts($args);
         $html = '';
         if (count($products)) {
             foreach ($products as $product) {
                 $html .= Fruitframe_Renderer::render_template_part('single-product', '', ['post' => $product, 'type' => $type]);
             }
         }
         $data = array('success' => 1, 'html' => $html, 'offset' => count($products));
     } catch (Exception $e) {
         $data = array('error' => 1, 'msg' => $e->getMessage());
     }
     echo json_encode($data);
     exit;
 }