protected function getAllReviews() { global $wpdb; $query = "SELECT comment_post_ID AS product_id, \n\t\t\t\t\t\t comment_author AS display_name, \n\t\t\t\t\t\t comment_date AS date,\n\t\t\t\t\t\t comment_author_email AS user_email, \n\t\t\t\t\t\t comment_content AS review_content, \n\t\t\t\t\t\t meta_value AS review_score,\n\t\t\t\t\t\t post_content AS product_description,\n\t\t\t\t\t\t post_title AS product_title,\n\t\t\t\t\t\t user_id\n\t\t\t\t FROM `" . $wpdb->prefix . "comments` \n\t\t\t\t INNER JOIN `" . $wpdb->prefix . "posts` ON `" . $wpdb->prefix . "posts`.`ID` = `" . $wpdb->prefix . "comments`.`comment_post_ID` \n\t\t\t\t INNER JOIN `" . $wpdb->prefix . "commentmeta` ON `" . $wpdb->prefix . "commentmeta`.`comment_id` = `" . $wpdb->prefix . "comments`.`comment_ID` \n\t\t\t\t WHERE `post_type` = 'product' AND meta_key='rating'"; $results = $wpdb->get_results($query); $all_reviews = array(); foreach ($results as $value) { $product_instance = get_product($value->product_id); $current_review = array(); $review_content = $this->cleanContent($value->review_content); $current_review['review_title'] = $this->getFirstWords($review_content); $current_review['review_content'] = $review_content; $current_review['display_name'] = $this->cleanContent($value->display_name); $current_review['user_email'] = $value->user_email; $current_review['user_type'] = woocommerce_customer_bought_product($value->user_email, $value->user_id, $value->product_id) ? 'verified_buyer' : ''; $current_review['review_score'] = $value->review_score; $current_review['date'] = $value->date; $current_review['sku'] = $value->product_id; $current_review['product_title'] = $this->cleanContent($value->product_title); $current_review['product_description'] = $this->cleanContent($product_instance->get_post_data()->post_excerpt); $current_review['product_url'] = get_permalink($value->product_id); $current_review['product_image_url'] = wc_yotpo_get_product_image_url($value->product_id); $all_reviews[] = $current_review; } return $all_reviews; }
function wc_yotpo_get_single_map_data($order_id) { $order = new WC_Order($order_id); $data = null; if (!is_null($order->id)) { $data = array(); $data['order_date'] = $order->order_date; $data['email'] = $order->billing_email; $data['customer_name'] = $order->billing_first_name . ' ' . $order->billing_last_name; $data['order_id'] = $order_id; $data['currency_iso'] = wc_yotpo_get_order_currency($order); $products_arr = array(); foreach ($order->get_items() as $product) { $product_instance = get_product($product['product_id']); $description = ''; if (is_object($product_instance)) { $description = strip_tags($product_instance->get_post_data()->post_excerpt); } $product_data = array(); $product_data['url'] = get_permalink($product['product_id']); $product_data['name'] = $product['name']; $product_data['image'] = wc_yotpo_get_product_image_url($product['product_id']); $product_data['description'] = $description; $product_data['price'] = $product['line_total']; $products_arr[$product['product_id']] = $product_data; } $data['products'] = $products_arr; } return $data; }