function blendercloud_has_starter_product() { // while we're updating the content return false; $user = wp_get_current_user(); $user_id = $user->ID; $user_email = $user->email; $starter_products = array(14, 73, 119, 120); $has_starter_product = false; foreach ($starter_products as $starter_product_id) { if (woocommerce_customer_bought_product($user_email, $user_id, $starter_product_id)) { $has_starter_product = true; break; } } return $has_starter_product; }
/** * Can review? * * Check if the current user can post a review. * Used to check if the user is a verified buyer. * * @since 1.1.0 */ public function can_post_review() { // Check if reviewing is restricted to verified buyer if (1 == get_option('wpjmr_restrict_review')) { $listing_id = get_the_ID(); $products = get_post_meta($listing_id, '_products', true); $current_user = wp_get_current_user(); if ($products) { foreach ($products as $product_id) { if (woocommerce_customer_bought_product($current_user->email, $current_user->ID, $product_id)) { return apply_filters('wpjmr_can_post_review', true); } } } // Default to false return apply_filters('wpjmr_can_post_review', false); } return apply_filters('wpjmr_can_post_review', true); }
if ($GLOBALS['comment']->comment_approved == '0') { ?> <p class="meta"><em><?php _e('Your comment is awaiting approval', 'woocommerce'); ?> </em></p> <?php } else { ?> <p class="meta"> <strong itemprop="author"><?php comment_author(); ?> </strong> <?php if (get_option('woocommerce_review_rating_verification_label') == 'yes') { if (woocommerce_customer_bought_product($GLOBALS['comment']->comment_author_email, $GLOBALS['comment']->user_id, $post->ID)) { echo '(' . __('verified owner', 'woocommerce') . ') '; } } ?> – <time itemprop="datePublished" time datetime="<?php echo get_comment_date('c'); ?> "><?php echo get_comment_date(__('M jS Y', 'woocommerce')); ?> </time>: </p> <?php } ?>
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; }