当前位置: 首页>>代码示例>>PHP>>正文


PHP wc_customer_bought_product函数代码示例

本文整理汇总了PHP中wc_customer_bought_product函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_customer_bought_product函数的具体用法?PHP wc_customer_bought_product怎么用?PHP wc_customer_bought_product使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wc_customer_bought_product函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkForProduct

 public static function checkForProduct($id)
 {
     $current_user = wp_get_current_user();
     $ids = str_replace(" ", '', $id);
     $ids = explode(",", $ids);
     foreach ($ids as $id) {
         $purchased = wc_customer_bought_product($current_user->user_email, $current_user->ID, $id);
         if ($purchased) {
             return $purchased;
         }
     }
 }
开发者ID:escobar022,项目名称:woocommerce-pay-per-post,代码行数:12,代码来源:woocommerce-payperpost.php

示例2: the_quiz_button

 function the_quiz_button($button, $quiz_id)
 {
     global $post;
     $quiz_id = get_the_ID();
     $user_id = get_current_user_id();
     $flag = 1;
     if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
         $pid = get_post_meta($quiz_id, 'vibe_quiz_product', true);
         if (isset($pid) && is_numeric($pid) && get_post_type($pid) == 'product') {
             $product_taken = wc_customer_bought_product('', $user_id, $pid);
             if (!$product_taken) {
                 $pid = get_permalink($pid);
                 $check = vibe_get_option('direct_checkout');
                 $check = intval($check);
                 if (isset($check) && $check) {
                     $pid .= '?redirect';
                 }
                 $flag = 0;
                 $html = '<a href="' . $pid . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>';
             } else {
                 $flag = 1;
             }
         }
     }
     if (in_array('paid-memberships-pro/paid-memberships-pro.php', apply_filters('active_plugins', get_option('active_plugins'))) && is_user_logged_in()) {
         $membership_ids = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_membership', false));
         if (!pmpro_hasMembershipLevel($membership_ids, $user_id) && isset($membership_ids) && count($membership_ids) >= 1) {
             $membership_taken = get_user_meta($user_id, $quiz_id, true);
             if (!$membership_taken) {
                 $pmpro_levels_page_id = get_option('pmpro_levels_page_id');
                 $link = get_permalink($pmpro_levels_page_id);
                 $html = '<a href="' . $link . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>';
                 $flag = 0;
             } else {
                 $flag = 1;
             }
         }
     }
     if (in_array('wplms-mycred-addon/wplms-mycred-addon.php', apply_filters('active_plugins', get_option('active_plugins')))) {
         $points = get_post_meta($quiz_id, 'vibe_quiz_mycred_points', true);
         $mycred = mycred();
         $balance = $mycred->get_users_cred($user_id);
         if ($balance < $points) {
             $flag = 0;
             $html = '<a href="#"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '<span>' . __('<br/>Not enough points.', 'vibe') . '</span></a>';
         }
         if (!$mycred->has_entry('purchase_quiz', $quiz_id, $user_id)) {
             $flag = 1;
             $deduct = -1 * $points;
             $mycred->update_users_balance($user_id, $deduct);
             $mycred->add_to_log('purchase_quiz', $user_id, $deduct, __('Student subscibed to quiz', 'wplms-mycred'), $quiz_id);
         } else {
             $flag = 1;
         }
     }
     if (!$flag) {
         return $html;
     }
     return $button;
 }
开发者ID:VibeThemes,项目名称:wplms_sell_quiz,代码行数:60,代码来源:sell_quiz.php

示例3: vibe_sell_content

 function vibe_sell_content($atts, $content = null)
 {
     extract(shortcode_atts(array('product_id' => ''), $atts));
     if (is_user_logged_in() && is_numeric($product_id)) {
         $user_id = get_current_user_id();
         $check = wc_customer_bought_product('', $user_id, $product_id);
         if ($check) {
             echo apply_filters('the_content', $content);
         } else {
             $product = get_product($product_id);
             if (is_object($product)) {
                 $link = get_permalink($product_id);
                 $check = vibe_get_option('direct_checkout');
                 if (isset($check) && $check) {
                     $link .= '?redirect';
                 }
                 $price_html = str_replace('class="amount"', 'class="amount" itemprop="price"', $product->get_price_html());
                 echo '<div class="message info">' . sprintf(__('You do not have access to this content. <a href="%s" class="button"> Puchase </a> content for %s', 'vibe-shortcodes'), $link, $price_html) . '</div>';
             } else {
                 echo '<div class="message info">' . __('You do not have access to this content', 'vibe-shortcodes') . '</div>';
             }
         }
     } else {
         $product = get_product($product_id);
         if (is_object($product)) {
             $link = get_permalink($product_id);
             $check = vibe_get_option('direct_checkout');
             if (isset($check) && $check) {
                 $link .= '?redirect';
             }
             $price_html = $product->get_price_html();
             echo '<div class="message info">' . sprintf(__('You do not have access to this content. <a href="%s" class="button"> Puchase </a> content for %s', 'vibe-shortcodes'), $link, $price_html) . '</div>';
         } else {
             echo '<div class="message info">' . __('You do not have access to this content', 'vibe-shortcodes') . '</div>';
         }
     }
     return $return;
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:38,代码来源:shortcodes.php

示例4: woocommerce_customer_bought_product

/**
 * @deprecated
 */
function woocommerce_customer_bought_product($customer_email, $user_id, $product_id)
{
    return wc_customer_bought_product($customer_email, $user_id, $product_id);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php

示例5: reviews

 /**
  * List of product reviews.
  *
  * ## OPTIONS
  *
  * <id>
  * : Product ID.
  *
  * [--field=<field>]
  * : Instead of returning the whole review fields, returns the value of a single fields.
  *
  * [--fields=<fields>]
  * : Get a specific subset of the review's fields.
  *
  * [--format=<format>]
  * : Accepted values: table, json, csv. Default: table.
  *
  * ## EXAMPLES
  *
  *     wp wc product reviews 123
  *
  *     wp wc product reviews 123 --fields=id,rating,reviewer_email
  *
  * @since 2.5.0
  */
 public function reviews($args, $assoc_args)
 {
     try {
         $id = $args[0];
         $product = wc_get_product($id);
         if (!$product) {
             throw new WC_CLI_Exception('woocommerce_cli_invalid_product', sprintf(__('Invalid product "%s"', 'woocommerce'), $id));
         }
         $comments = get_approved_comments($id);
         $reviews = array();
         foreach ($comments as $comment) {
             $reviews[] = array('id' => intval($comment->comment_ID), 'created_at' => $this->format_datetime($comment->comment_date_gmt), 'review' => $comment->comment_content, 'rating' => get_comment_meta($comment->comment_ID, 'rating', true), 'reviewer_name' => $comment->comment_author, 'reviewer_email' => $comment->comment_author_email, 'verified' => (bool) wc_customer_bought_product($comment->comment_author_email, $comment->user_id, $id));
         }
         if (empty($assoc_args['fields'])) {
             $assoc_args['fields'] = $this->get_review_fields();
         }
         $formatter = $this->get_formatter($assoc_args);
         $formatter->display_items($reviews);
     } catch (WC_CLI_Exception $e) {
         WP_CLI::error($e->getMessage());
     }
 }
开发者ID:rjagadishsingh,项目名称:woocommerce,代码行数:47,代码来源:class-wc-cli-product.php

示例6: add_comment_purchase_verification

 /**
  * Determine if a review is from a verified owner at submission.
  * @param int $comment_id
  * @return bool
  */
 public static function add_comment_purchase_verification($comment_id)
 {
     $comment = get_comment($comment_id);
     $verified = false;
     if ('product' === get_post_type($comment->comment_post_ID)) {
         $verified = wc_customer_bought_product($comment->comment_author_email, $comment->user_id, $comment->comment_post_ID);
         add_comment_meta($comment_id, 'verified', (int) $verified, true);
     }
     return $verified;
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:15,代码来源:class-wc-comments.php

示例7: extract

<?php

extract(shortcode_atts(array('title' => '', 'icon' => '', 'private_lesson' => '', 'badge' => '', 'meta' => '', 'meta_icon' => '', 'preview_video' => '', 'private_placeholder' => '', 'css' => ''), $atts));
$css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, vc_shortcode_custom_css_class($css, ' '));
$stm_tab_id = 'tab' . rand(0, 9999);
$tapableTab = '';
if (!empty($content)) {
    $tapableTab = 'tapable';
}
// Get current user and check if he bought current course
$bought_course = false;
$current_user = wp_get_current_user();
if (!empty($current_user->user_email) and !empty($current_user->ID)) {
    if (wc_customer_bought_product($current_user->user_email, $current_user->ID, get_the_id())) {
        $bought_course = true;
    }
}
?>

<div class="panel panel-default">
	<div class="panel-heading" role="tab" id="heading_<?php 
echo esc_attr($stm_tab_id);
?>
">
		<div class="course_meta_data">
			<div class="panel-title">
				<a class="collapsed <?php 
echo esc_attr($tapableTab);
?>
" role="button" data-toggle="collapse"  href="#<?php 
echo esc_attr($stm_tab_id);
开发者ID:rinodung,项目名称:master-study-wordpress,代码行数:31,代码来源:stm_course_lesson.php

示例8: woo_tied_evaluate_access

 /**
  * Check conditions.
  *
  * @param  int $item_id
  * @return boolean
  */
 public function woo_tied_evaluate_access($item_id)
 {
     $tied_product_ids = get_post_meta($item_id, '_tied_products', true);
     $dependency_type = absint(get_post_meta($item_id, '_dependency_type', true));
     if ($tied_product_ids) {
         $tied_product_ids = array_values(get_post_meta($item_id, '_tied_products', true));
         // Check cart
         if ($dependency_type === 2 || $dependency_type === 3) {
             $cart_contents = WC()->cart->cart_contents;
             foreach ($cart_contents as $cart_item) {
                 $product_id = $cart_item['product_id'];
                 if (in_array($product_id, $tied_product_ids)) {
                     return true;
                 }
             }
         }
         // Check ownership
         if (is_user_logged_in() && ($dependency_type === 1 || $dependency_type === 3)) {
             global $current_user;
             get_currentuserinfo();
             $is_owner = false;
             foreach ($tied_product_ids as $id) {
                 if (wc_customer_bought_product($current_user->user_email, $current_user->ID, $id)) {
                     $is_owner = true;
                 }
             }
             if (!$is_owner) {
                 $product_titles = array();
                 foreach ($tied_product_ids as $id) {
                     if ($tied_product_ids[count($tied_product_ids) - 1] === $id) {
                         $product_titles[] = sprintf(__(' or &quot;%s&quot;', 'woocommerce-product-dependencies'), get_the_title($id));
                     } elseif ($tied_product_ids[0] === $id) {
                         $product_titles[] = sprintf(__('&quot;%s&quot;', 'woocommerce-product-dependencies'), get_the_title($id));
                     } else {
                         $product_titles[] = sprintf(__(', &quot;%s&quot;', 'woocommerce-product-dependencies'), get_the_title($id));
                     }
                 }
                 if (is_rtl()) {
                     $product_titles = array_reverse($product_titles);
                 }
                 if ($dependency_type === 1) {
                     wc_add_notice(sprintf(__('Access to &quot;%2$s&quot; is restricted only to verified owners of %1$s.', 'woocommerce-product-dependencies'), implode('', $product_titles), get_the_title($item_id)), 'error');
                 } else {
                     wc_add_notice(sprintf(__('Access to &quot;%2$s&quot; is restricted only to verified owners of %1$s. Alternatively, access to this item will be granted after adding a %1$s to the cart.', 'woocommerce-product-dependencies'), implode('', $product_titles), get_the_title($item_id)), 'error');
                 }
                 return false;
             }
         } else {
             $product_titles = array();
             foreach ($tied_product_ids as $id) {
                 if ($tied_product_ids[count($tied_product_ids) - 1] === $id) {
                     $product_titles[] = sprintf(__(' or &quot;%s&quot;', 'woocommerce-product-dependencies'), get_the_title($id));
                 } elseif ($tied_product_ids[0] === $id) {
                     $product_titles[] = sprintf(__('&quot;%s&quot;', 'woocommerce-product-dependencies'), get_the_title($id));
                 } else {
                     $product_titles[] = sprintf(__(', &quot;%s&quot;', 'woocommerce-product-dependencies'), get_the_title($id));
                 }
             }
             if (is_rtl()) {
                 $product_titles = array_reverse($product_titles);
             }
             $msg = '';
             if ($dependency_type === 1) {
                 $msg = __('Access to &quot;%2$s&quot; is restricted only to verified owners of %1$s. The verification is automatic and simply requires you to be <a href="%3$s">logged in</a>.', 'woocommerce-product-dependencies');
             } elseif ($dependency_type === 2) {
                 $msg = __('&quot;%2$s&quot; can be purchased only in combination with %1$s. Access to this item will be granted after adding a %1$s to the cart.', 'woocommerce-product-dependencies');
             } else {
                 $msg = __('&quot;%2$s&quot; requires the purchase of %1$s. Ownership can be verified by simply <a href="%3$s">logging in</a>. Alternatively, access to this item will be granted after adding a %1$s to the cart.', 'woocommerce-product-dependencies');
             }
             wc_add_notice(sprintf($msg, implode('', $product_titles), get_the_title($item_id), wp_login_url()), 'error');
             return false;
         }
     }
     return true;
 }
开发者ID:ennost,项目名称:woocommerce-product-dependencies,代码行数:81,代码来源:woocommerce-product-dependencies.php

示例9: get_wooc_product_data

 public function get_wooc_product_data()
 {
     global $post, $the_product;
     $user_data = $this->user_data;
     $user_email = $user_data->email;
     $user_ID = $user_data->user_id;
     $orders_data = array();
     $order_products = array();
     include_once dirname(WC_PLUGIN_FILE) . '/includes/admin/class-wc-admin-post-types.php';
     $CPT_Product = new WC_Admin_Post_Types();
     $args = array('numberposts' => -1, 'post_type' => 'product', 'post_status' => 'publish');
     #$products = get_posts( $args );
     $products = wcrm_customer_bought_products($user_email, $user_ID);
     foreach ($products as $prod) {
         $post = get_post($prod->ID);
         $the_product = wc_get_product($prod->ID);
         if (!wc_customer_bought_product($user_email, $user_ID, $prod->ID)) {
             # continue;
         }
         $o['ID'] = $prod->ID;
         ob_start();
         $CPT_Product->render_product_columns('thumb');
         $o['thumb'] = ob_get_contents();
         ob_end_clean();
         ob_start();
         $edit_link = get_edit_post_link($prod->ID);
         $title = _draft_or_post_title();
         echo '<strong><a class="row-title" href="' . $edit_link . '">' . $title . '</a>';
         $o['name'] = ob_get_contents();
         ob_end_clean();
         ob_start();
         $CPT_Product->render_product_columns('sku');
         $o['sku'] = ob_get_contents();
         ob_end_clean();
         $o['number_purchased'] = $prod->items_count;
         $o['value_purchases'] = wc_price($prod->line_total);
         $orders_data[] = $o;
     }
     return $orders_data;
 }
开发者ID:sajidshah,项目名称:le-dolci,代码行数:40,代码来源:wc_crm_customer_product_list.php

示例10: _e

				<p class="meta"><em><?php 
    _e('Your comment is waiting for approval', 'yith-woocommerce-advanced-reviews');
    ?>
</em></p>

			<?php 
} else {
    ?>

				<p class="meta">
					<strong itemprop="author"><?php 
    echo $author_name;
    ?>
</strong> <?php 
    if ($user && get_option('woocommerce_review_rating_verification_label') === 'yes') {
        if (wc_customer_bought_product($user->user_email, $user->ID, $product_id)) {
            echo '<em class="verified">(' . __('verified owner', 'yith-woocommerce-advanced-reviews') . ')</em> ';
        }
    }
    ?>
					<time itemprop="datePublished"
					      datetime="<?php 
    echo mysql2date('c', $review_date);
    ?>
"><?php 
    echo $review_date;
    ?>
</time>
				</p>

			<?php 
开发者ID:yarwalker,项目名称:ecobyt,代码行数:31,代码来源:ywar-review.php

示例11: array

			</figure>
		<?php 
}
?>
		<p class="info">
			<?php 
if ($rating && get_option('woocommerce_enable_review_rating') == 'yes') {
    ?>
				<?php 
    Everything::shortcodeOutput('rating', array('rate' => $rating . '/5', 'advanced_tag' => 'small'));
    ?>
			<?php 
}
?>
			<?php 
if (get_option('woocommerce_review_rating_verification_label') == 'yes' && wc_customer_bought_product($comment->comment_author_email, $comment->user_id, $comment->comment_post_ID)) {
    ?>
				<small>
					<?php 
    _e('verified owner', 'woocommerce');
    ?>
				</small>
			<?php 
}
?>
			<strong><?php 
comment_author();
?>
</strong>
			<?php 
if (Everything::to('site/comments/date_format')) {
开发者ID:xpander54,项目名称:wp-drz,代码行数:31,代码来源:review.php

示例12: comment_author

            <?php 
} else {
    ?>

                <p class="meta">

                <span class="vcard author" itemprop="author">
                        <span class="fn"><?php 
    comment_author();
    ?>
</span>
                    </span>

                <?php 
    if (get_option('woocommerce_review_rating_verification_label') == 'yes') {
        if (wc_customer_bought_product($GLOBALS['comment']->comment_author_email, $GLOBALS['comment']->user_id, $post->ID)) {
            echo '<em class="verified">(' . __('verified owner', 'yit') . ')</em> ';
        }
    }
    ?>

                <time class='timestamp-link' expr:href='data:post.url' title='permanent link' itemprop="datePublished" content="<?php 
    echo get_comment_date('Y-m-d');
    ?>
">
                    <abbr class='updated published' expr:title='data:post.timestampISO8601'>
                        <data:post.timestamp />
                        <?php 
    echo get_comment_date(__(get_option('date_format'), 'yit'));
    ?>
                    </abbr>
开发者ID:jayeshnair,项目名称:ctp,代码行数:31,代码来源:review.php

示例13: wplms_events_invite_buttons

 function wplms_events_invite_buttons($invite)
 {
     //1 Means show breadcrumbs, 0 means show buttons
     $private_event = get_post_meta(get_the_ID(), 'vibe_private_event', true);
     if (isset($private_event) && $private_event == 'S') {
         global $post;
         $current_user = wp_get_current_user();
         $product = get_post_meta(get_the_ID(), 'vibe_product', true);
         if (isset($product) && $product) {
             // get user attributes
             // determine if customer has bought product
             if (wc_customer_bought_product($current_user->email, $current_user->ID, $product->id)) {
                 return 0;
             } else {
                 return 1;
             }
         }
         return 1;
     }
     return $invite;
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:21,代码来源:events_class.php

示例14: _e

				<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 (version_compare($porto_woo_version, '2.5', '>=') ? $verified : wc_customer_bought_product($comment->comment_author_email, $comment->user_id, $comment->comment_post_ID)) {
            echo '<em class="verified">(' . __('verified owner', 'woocommerce') . ')</em> ';
        }
    }
    ?>
&ndash; <time itemprop="datePublished" datetime="<?php 
    echo get_comment_date('c');
    ?>
"><?php 
    echo get_comment_date(wc_date_format());
    ?>
</time>
				</p>

			<?php 
}
开发者ID:booklein,项目名称:wpbookle,代码行数:31,代码来源:review.php

示例15: next_comments_link

				<div class="nav-next"><?php 
            next_comments_link(__('Next ', 'thefoxwp'));
            ?>
<span class="meta-nav">&rarr;</span></div>
			</div>
		<?php 
        }
        echo '<p class="add_review"><a href="#review_form" class="inline show_review_form button" title="' . __('Add Your Review', 'thefoxwp') . '">' . __('Add Review', 'thefoxwp') . '</a></p>';
        $title_reply = __('Add a review', 'thefoxwp');
    } else {
        $title_reply = __('Be the first to review', 'thefoxwp') . ' &ldquo;' . $post->post_title . '&rdquo;';
        echo '<p class="noreviews">' . sprintf(__('There are no reviews yet, would you like to <a href="%s" class="inline show_review_form">submit yours</a>?', 'thefoxwp'), '#review_form') . '</p>';
    }
    $commenter = wp_get_current_commenter();
    echo '</div>';
    if (get_option('woocommerce_review_rating_verification_required') === 'no' || wc_customer_bought_product('', get_current_user_id(), $product->id)) {
        ?>
	<div id="review_form_wrapper"><div id="review_form">
	<?php 
        $comment_form = array('title_reply' => $title_reply, 'comment_notes_before' => '', 'comment_notes_after' => '', 'fields' => array('author' => '<p class="comment-form-author">' . '<label for="author">' . __('Name', 'thefoxwp') . '</label> ' . '<span class="required">*</span>' . '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30" aria-required="true" /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __('Email', 'thefoxwp') . '</label> ' . '<span class="required">*</span>' . '<input id="email" name="email" type="text" value="' . esc_attr($commenter['comment_author_email']) . '" size="30" aria-required="true" /></p>'), 'label_submit' => __('Submit Review', 'thefoxwp'), 'logged_in_as' => '', 'comment_field' => '');
        if (get_option('woocommerce_enable_review_rating') == 'yes') {
            $comment_form['comment_field'] = '<p class="comment-form-rating"><label for="rating">' . __('Rating', 'thefoxwp') . '</label><select name="rating" id="rating">
			<option value="">' . __('Rate&hellip;', 'thefoxwp') . '</option>
			<option value="5">' . __('Perfect', 'thefoxwp') . '</option>
			<option value="4">' . __('Good', 'thefoxwp') . '</option>
			<option value="3">' . __('Average', 'thefoxwp') . '</option>
			<option value="2">' . __('Not that bad', 'thefoxwp') . '</option>
			<option value="1">' . __('Very Poor', 'thefoxwp') . '</option>
		</select></p>';
        }
        $comment_form['comment_field'] .= '<p class="comment-form-comment"><label for="comment">' . __('Your Review', 'thefoxwp') . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>' . wp_nonce_field('comment_rating', true, false);
开发者ID:axelander95,项目名称:wsguiavirtualpichincha,代码行数:31,代码来源:single-product-reviews.php


注:本文中的wc_customer_bought_product函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。