本文整理汇总了PHP中WooThemes_Sensei_Utils::sensei_customer_bought_product方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::sensei_customer_bought_product方法的具体用法?PHP WooThemes_Sensei_Utils::sensei_customer_bought_product怎么用?PHP WooThemes_Sensei_Utils::sensei_customer_bought_product使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WooThemes_Sensei_Utils
的用法示例。
在下文中一共展示了WooThemes_Sensei_Utils::sensei_customer_bought_product方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: woocommerce_course_update
/**
* If WooCommerce is activated and the customer has purchased the course, update Sensei to indicate that they are taking the course.
* @access public
* @since 1.0.0
* @param int $course_id (default: 0)
* @param array/Object $order_user (default: array()) Specific user's data.
* @return void
*/
public function woocommerce_course_update($course_id = 0, $order_user = array())
{
global $current_user;
if (!isset($current_user)) {
return;
}
$data_update = false;
// Get the product ID
$wc_post_id = get_post_meta(intval($course_id), '_course_woocommerce_product', true);
// Check if in the admin
if (is_admin()) {
$user_login = $order_user['user_login'];
$user_email = $order_user['user_email'];
$user_url = $order_user['user_url'];
$user_id = $order_user['ID'];
} else {
$user_login = $current_user->user_login;
$user_email = $current_user->user_email;
$user_url = $current_user->user_url;
$user_id = $current_user->ID;
}
// End If Statement
// This doesn't appear to be purely WooCommerce related. Should it be in a separate function?
$course_prerequisite_id = (int) get_post_meta($course_id, '_course_prerequisite', true);
if (0 < absint($course_prerequisite_id)) {
$prereq_course_complete = WooThemes_Sensei_Utils::user_completed_course($course_prerequisite_id, intval($user_id));
if (!$prereq_course_complete) {
// Remove all course user meta
return WooThemes_Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id);
}
}
$is_user_taking_course = WooThemes_Sensei_Utils::user_started_course(intval($course_id), intval($user_id));
if (!$is_user_taking_course) {
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && WooThemes_Sensei_Utils::sensei_customer_bought_product($user_email, $user_id, $wc_post_id) && 0 < $wc_post_id) {
$activity_logged = WooThemes_Sensei_Utils::user_start_course(intval($user_id), intval($course_id));
$is_user_taking_course = false;
if (true == $activity_logged) {
$is_user_taking_course = true;
}
// End If Statement
}
// End If Statement
}
return $is_user_taking_course;
}
示例2: sensei_lesson_course_signup_link
public function sensei_lesson_course_signup_link($course_id = 0)
{
if (0 < intval($course_id)) {
?>
<section class="lesson-meta"><?php
$course_link = '<a href="' . esc_url(get_permalink($course_id)) . '">' . __('course', 'woothemes-sensei') . '</a>';
$wc_post_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && 0 < $wc_post_id) {
global $current_user;
if (is_user_logged_in()) {
wp_get_current_user();
$course_purchased = WooThemes_Sensei_Utils::sensei_customer_bought_product($current_user->user_email, $current_user->ID, $wc_post_id);
if ($course_purchased) {
$prereq_course_id = get_post_meta($course_id, '_course_prerequisite', true);
?>
<div class="sensei-message info"><?php
echo apply_filters('sensei_complete_prerequisite_course_text', sprintf(__('Please complete %1$s before starting the lesson.', 'woothemes-sensei'), '<a href="' . esc_url(get_permalink($prereq_course_id)) . '" title="' . esc_attr(get_the_title($prereq_course_id)) . '">' . apply_filters('sensei_previous_course_text', __('the previous course', 'woothemes-sensei')) . '</a>'));
?>
</div>
<?php
} else {
?>
<div class="sensei-message info"><?php
echo apply_filters('sensei_please_purchase_course_text', sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), '<a href="' . esc_url(get_permalink($course_id)) . '" title="' . esc_attr(apply_filters('sensei_sign_up_text', __('Sign Up', 'woothemes-sensei'))) . '">' . __('course', 'woothemes-sensei') . '</a>'));
?>
</div>
<?php
}
} else {
?>
<div class="sensei-message info"><?php
echo apply_filters('sensei_please_purchase_course_text', sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), '<a href="' . esc_url(get_permalink($course_id)) . '" title="' . esc_attr(apply_filters('sensei_sign_up_text', __('Sign Up', 'woothemes-sensei'))) . '">' . __('course', 'woothemes-sensei') . '</a>'));
?>
</div>
<?php
}
?>
<?php
} else {
?>
<div class="sensei-message info">
<?php
/**
* Filter the Sensei please sign up message
* @since 1.4.0
*
* @param string $signup_text
*/
echo apply_filters('sensei_please_sign_up_text', sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), '<a href="' . esc_url(get_permalink($course_id)) . '" title="' . esc_attr(apply_filters('sensei_sign_up_text', __('Sign Up', 'woothemes-sensei'))) . '">' . __('course', 'woothemes-sensei') . '</a>'));
?>
</div>
<?php
}
// End If Statement
?>
</section><?php
}
// End If Statement
}
示例3: the_course_action_buttons
/**
* Prints out the course action buttons links
*
* - complete course
* - delete course
*
* @param WP_Post $course
*/
public static function the_course_action_buttons($course)
{
if (is_user_logged_in()) {
?>
<section class="entry-actions">
<form method="POST" action="<?php
echo esc_url(remove_query_arg(array('active_page', 'completed_page')));
?>
">
<input type="hidden"
name="<?php
esc_attr_e('woothemes_sensei_complete_course_noonce');
?>
"
id="<?php
esc_attr_e('woothemes_sensei_complete_course_noonce');
?>
"
value="<?php
esc_attr_e(wp_create_nonce('woothemes_sensei_complete_course_noonce'));
?>
"
/>
<input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php
esc_attr_e(intval($course->ID));
?>
" />
<?php
if (0 < absint(count(Sensei()->course->course_lessons($course->ID))) && Sensei()->settings->settings['course_completion'] == 'complete') {
?>
<span><input name="course_complete" type="submit" class="course-complete" value="<? echo apply_filters( 'sensei_mark_as_complete_text', __( 'Mark as Complete', 'woothemes-sensei' ) ); ?>/></span>
<?php
}
// End If Statement
$course_purchased = false;
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
// Get the product ID
$wc_post_id = get_post_meta(intval($course->ID), '_course_woocommerce_product', true);
if (0 < $wc_post_id) {
$user = wp_get_current_user();
$course_purchased = WooThemes_Sensei_Utils::sensei_customer_bought_product($user->user_email, $user->ID, $wc_post_id);
}
// End If Statement
}
// End If Statement
if (!$course_purchased && !WooThemes_Sensei_Utils::user_completed_course($course->ID, get_current_user_id())) {
?>
<span><input name="course_complete" type="submit" class="course-delete" value="<?php
echo apply_filters('sensei_delete_course_text', __('Delete Course', 'woothemes-sensei'));
?>
"/></span>
<?php
}
// End If Statement
$has_quizzes = Sensei()->course->course_quizzes($course->ID, true);
$results_link = '';
if ($has_quizzes) {
$results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink($course->ID) . '">' . apply_filters('sensei_view_results_text', __('View results', 'woothemes-sensei')) . '</a>';
}
// Output only if there is content to display
if (has_filter('sensei_results_links') || $has_quizzes) {
?>
<p class="sensei-results-links">
<?php
echo apply_filters('sensei_results_links', $results_link);
?>
</p>
<?php
}
// end if has filter
?>
</form>
</section>
<?php
}
// end if is user logged in
}
示例4: load_user_courses_content
//.........这里部分代码省略.........
// Lesson count for this author
$lesson_count = $woothemes_sensei->post_types->course->course_lesson_count(absint($course_item->ID));
// Handle Division by Zero
if (0 == $lesson_count) {
$lesson_count = 1;
}
// End If Statement
$active_html .= '<span class="course-lesson-count">' . $lesson_count . ' ' . apply_filters('sensei_lessons_text', __('Lessons', 'woothemes-sensei')) . '</span>';
// Course Categories
if ('' != $category_output) {
$active_html .= '<span class="course-category">' . sprintf(__('in %s', 'woothemes-sensei'), $category_output) . '</span>';
}
// End If Statement
$active_html .= '<span class="course-lesson-progress">' . sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $lessons_completed, $lesson_count) . '</span>';
$active_html .= '</p>';
$active_html .= '<p class="course-excerpt">' . apply_filters('get_the_excerpt', $course_item->post_excerpt) . '</p>';
$progress_percentage = abs(round(doubleval($lessons_completed) * 100 / $lesson_count, 0));
$active_html .= $this->get_progress_meter($progress_percentage);
$active_html .= '</section>';
if ($manage) {
$active_html .= '<section class="entry-actions">';
$active_html .= '<form method="POST" action="' . esc_url(remove_query_arg(array('active_page', 'completed_page'))) . '">';
$active_html .= '<input type="hidden" name="' . esc_attr('woothemes_sensei_complete_course_noonce') . '" id="' . esc_attr('woothemes_sensei_complete_course_noonce') . '" value="' . esc_attr(wp_create_nonce('woothemes_sensei_complete_course_noonce')) . '" />';
$active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr(absint($course_item->ID)) . '" />';
if (0 < absint(count($course_lessons)) && $woothemes_sensei->settings->settings['course_completion'] == 'complete') {
$active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="' . apply_filters('sensei_mark_as_complete_text', __('Mark as Complete', 'woothemes-sensei')) . '"/></span>';
}
// End If Statement
$course_purchased = false;
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
// Get the product ID
$wc_post_id = get_post_meta(absint($course_item->ID), '_course_woocommerce_product', true);
if (0 < $wc_post_id) {
$course_purchased = WooThemes_Sensei_Utils::sensei_customer_bought_product($user->user_email, $user->ID, $wc_post_id);
}
// End If Statement
}
// End If Statement
if (!$course_purchased) {
$active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="' . apply_filters('sensei_delete_course_text', __('Delete Course', 'woothemes-sensei')) . '"/></span>';
}
// End If Statement
$active_html .= '</form>';
$active_html .= '</section>';
}
$active_html .= '</article>';
}
// Active pagination
if ($active_count > $per_page) {
$current_page = 1;
if (isset($_GET['active_page']) && 0 < intval($_GET['active_page'])) {
$current_page = $_GET['active_page'];
}
$active_html .= '<nav class="pagination woo-pagination">';
$total_pages = ceil($active_count / $per_page);
$link = '';
if ($current_page > 1) {
$prev_link = add_query_arg('active_page', $current_page - 1);
$active_html .= '<a class="prev page-numbers" href="' . esc_url($prev_link) . '">' . __('Previous', 'woothemes-sensei') . '</a> ';
}
for ($i = 1; $i <= $total_pages; $i++) {
$link = add_query_arg('active_page', $i);
if ($i == $current_page) {
$active_html .= '<span class="page-numbers current">' . $i . '</span> ';
} else {
$active_html .= '<a class="page-numbers" href="' . esc_url($link) . '">' . $i . '</a> ';
示例5: get_post_meta
*
* Override this template by copying it to yourtheme/sensei/woocommerce/add-to-cart.php
*
* @author WooThemes
* @package Sensei/Templates
* @version 1.0.0
*/
if (!defined('ABSPATH')) {
exit;
}
global $post, $current_user, $woocommerce, $woothemes_sensei;
$wc_post_id = get_post_meta($post->ID, '_course_woocommerce_product', true);
// Get User Meta
get_currentuserinfo();
// Check if customer purchased the product
if (WooThemes_Sensei_Utils::sensei_customer_bought_product($current_user->user_email, $current_user->ID, $wc_post_id)) {
?>
<div class="sensei-message tick"><?php
_e('You are currently taking this course.', 'woothemes-sensei');
?>
</div>
<?php
} else {
// based on simple.php in WC templates/single-product/add-to-cart/
if (0 < $wc_post_id) {
// Get the product
$product = $woothemes_sensei->sensei_get_woocommerce_product_object($wc_post_id);
if (!isset($product) || !is_object($product)) {
exit;
}
if ($product->is_purchasable()) {