";print_r($vars);exit; return $vars; } /** * check for 'my_plugin' query variable and do what you want if its there */ add_action('template_redirect', 'ar_woo_my_template'); function ar_woo_my_template($template) { global $wp_query; if (!isset($wp_query->query['ar_woo_product'])) return $template; if ($wp_query->query['ar_woo_product'] == 'productList') { $Domain_name = $_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI']; $fetch_url = strtok($Domain_name, '?'); $match_parse = rtrim($fetch_url, '/'); $nonce = decryptIt($_REQUEST['nonce']); if ((isset($nonce) != '') && $nonce != $match_parse) { echo "Not secure Connection"; exit; } $fetch_count = ar_curl_call(ar_woo_register_on_plugin . 'plugin_status.php'); $fetch_result = json_decode($fetch_count); $fetch_count_result = $fetch_result->count_result; $data = json_decode(file_get_contents('php://input'), true); $order = ($data['order']) ? $data['order'] : ""; $page = ($data['page_num']) ? $data['page_num'] : ""; $category = ($data['category']) ? $data['category'] : ""; $order = sanitize_text_field($order); $page = sanitize_text_field($page); $category = sanitize_text_field($category); if ($order != '' && $page != '' && $category != '') { $args = array('post_type' => 'product', 'paged' => $page, 'order' => $order, 'posts_per_page' => $fetch_count_result, 'post_status' => 'publish', "orderby" => 'title', 'meta_key' => 'ar_woo_product_Detail', 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $category, ), ) ); $loop = new WP_Query($args); $product_list = array(); $count = $loop->post_count; if ($count > 0) { while ($loop->have_posts()) : $loop->the_post(); global $product; $get_model_check = get_post_meta($product->post->ID, 'ar_woo_product_Detail', true); if (!empty($get_model_check)) { /* * ********* Get Product Image ********** */ $get_product_image = wp_get_attachment_image_src(get_post_thumbnail_id($product->post->ID), 'single-post-thumbnail'); if ($get_product_image[0]) { $product_image = $get_product_image[0]; } else { $product_image = ''; } /** * ******** End ************ */ $category = get_the_terms($product->ID, 'product_cat'); $get_categoty = $category[0]; // Get Ptoduct Category $get_categoty->name = html_entity_decode($category[0]->name); /* $get_model = get_post_meta($product->post->ID, 'ar_woo_product_Detail', true); // Get Models Detail if(!empty($get_model)){ $model = $get_model; }else{ $model = []; } */ $image_attachment = json_decode($product); $image_attachment->category = $get_categoty; $image_attachment->product_image = $product_image; $image_attachment->meta_data = $get_model_check; $image_attachment->productUrl = get_permalink($post_id); $image_attachment->currencySymbol = get_woocommerce_currency_symbol(); //; //get_option('woocommerce_currency'); $value = get_post_meta( $product->post->ID, 'app_description', true ); $image_attachment->description = $value; $product_list[] = $image_attachment; } endwhile; $show_getproduct = array("status" => 200, 'msg' => "Successfully Product Found", "product" => $product_list); } else { $show_getproduct = array("status" => 400, 'msg' => "No Product Availabel", "product" => ''); } } else { $show_getproduct = array("status" => 401, 'msg' => "Please Enter all parameter", "product" => ''); } echo json_encode($show_getproduct); wp_reset_query(); exit; } return $template; } ?>