";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_single_pro_woo_my_template'); function ar_woo_single_pro_woo_my_template($template) { global $wp_query; if (!isset($wp_query->query['single_product'])) return $template; if ($wp_query->query['single_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; //$product_id = $_REQUEST['product_id']; $get_product_id = ($_REQUEST['product_id']) ? $_REQUEST['product_id'] : ""; $product_id = sanitize_text_field($get_product_id); if ($product_id != '') { $args = array('p' => $product_id, 'post_type' => 'product'); $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 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); //echo $product->post->ID;exit; $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 = $model; $image_attachment->productUrl = get_permalink($post_id); $value = get_post_meta( $product->post->ID, 'app_description', true ); $image_attachment->description = $value; $image_attachment->currencySymbol = get_woocommerce_currency_symbol(); ; //get_option('woocommerce_currency'); $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 Avialabel", "product" => ''); } } else { $show_getproduct = array("status" => 401, 'msg' => "Please Enter all parameter", "product" => ''); } echo json_encode($show_getproduct); wp_reset_query(); exit; } return $template; } ?>