Version Description
25 March, 2019 =
Added: WooCommerce and EDD support to sell courses
Download this release
Release Info
Developer | themeum |
Plugin | Tutor LMS – eLearning and online course solution |
Version | 1.0.8 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.0.8
- assets/css/tutor-front.css +13 -0
- assets/js/tutor-front.js +1 -1
- classes/TutorEDD.php +152 -0
- classes/Utils.php +12 -0
- classes/WooCommerce.php +269 -0
- classes/init.php +6 -1
- readme.txt +7 -1
- tutor.php +2 -2
- views/metabox/course-add-edd-product-metabox.php +41 -0
assets/css/tutor-front.css
CHANGED
@@ -1610,6 +1610,19 @@ Instructor
|
|
1610 |
width: 100%;
|
1611 |
text-align: center;
|
1612 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1613 |
|
1614 |
/*******************/
|
1615 |
/*tutor review form*/
|
1610 |
width: 100%;
|
1611 |
text-align: center;
|
1612 |
}
|
1613 |
+
.tutor-single-add-to-cart-box.cart-required-login {
|
1614 |
+
position: relative;
|
1615 |
+
}
|
1616 |
+
.tutor-single-add-to-cart-box.cart-required-login:before{
|
1617 |
+
position: absolute;
|
1618 |
+
content: "";
|
1619 |
+
top: 0;
|
1620 |
+
bottom: 0;
|
1621 |
+
left: 0;
|
1622 |
+
right: 0;
|
1623 |
+
z-index: 99;
|
1624 |
+
cursor: pointer;
|
1625 |
+
}
|
1626 |
|
1627 |
/*******************/
|
1628 |
/*tutor review form*/
|
assets/js/tutor-front.js
CHANGED
@@ -529,7 +529,7 @@ jQuery(document).ready(function($){
|
|
529 |
* @since v.1.0.4
|
530 |
*/
|
531 |
|
532 |
-
$(document).on('submit', '.cart-required-login form', function (e) {
|
533 |
e.preventDefault();
|
534 |
|
535 |
$('.tutor-cart-box-login-form').fadeIn(100);
|
529 |
* @since v.1.0.4
|
530 |
*/
|
531 |
|
532 |
+
$(document).on('submit click', '.cart-required-login, .cart-required-login a, .cart-required-login form', function (e) {
|
533 |
e.preventDefault();
|
534 |
|
535 |
$('.tutor-cart-box-login-form').fadeIn(100);
|
classes/TutorEDD.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Tutor Course attachments Main Class
|
4 |
+
*/
|
5 |
+
|
6 |
+
namespace TUTOR;
|
7 |
+
|
8 |
+
class TutorEDD extends Tutor_Base {
|
9 |
+
|
10 |
+
public function __construct() {
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
add_action('tutor_options_before_tutor_edd', array($this, 'notice_before_option'));
|
14 |
+
|
15 |
+
//Add Tutor Option
|
16 |
+
add_filter('tutor/options/attr', array($this, 'add_options'));
|
17 |
+
|
18 |
+
$course_sell = tutor_utils()->get_option('enable_tutor_edd');
|
19 |
+
if ( ! $course_sell){
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
|
23 |
+
add_action( 'add_meta_boxes', array($this, 'register_meta_box') );
|
24 |
+
add_action('save_post_'.$this->course_post_type, array($this, 'save_course_meta'));
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Is Course Purchasable
|
28 |
+
*/
|
29 |
+
add_filter('is_course_purchasable', array($this, 'is_course_purchasable'), 10, 2);
|
30 |
+
add_filter('get_tutor_course_price', array($this, 'get_tutor_course_price'), 10, 2);
|
31 |
+
add_filter('tutor_course_sell_by', array($this, 'tutor_course_sell_by'));
|
32 |
+
|
33 |
+
add_action('edd_update_payment_status', array($this, 'edd_update_payment_status'), 10, 3);
|
34 |
+
}
|
35 |
+
|
36 |
+
public function notice_before_option(){
|
37 |
+
$has_edd = tutor_utils()->has_edd();
|
38 |
+
if ($has_edd){
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
|
42 |
+
ob_start();
|
43 |
+
?>
|
44 |
+
<div class="tutor-notice-warning">
|
45 |
+
<p>
|
46 |
+
<?php _e(' Seems like you don’t have <strong>Easy Digital Downloads</strong> plugin installed on your site. In order to use this functionality, you need to have the <strong>Easy Digital Downloads</strong> plugin installed. Get back on this page after installing the plugin and enable the following feature to start selling courses with Tutor.', 'tutor'); ?>
|
47 |
+
</p>
|
48 |
+
<p><?php _e('This notice will disappear after activating <strong>EDD</strong>', 'tutor'); ?></p>
|
49 |
+
</div>
|
50 |
+
<?php
|
51 |
+
echo ob_get_clean();
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @param $attr
|
56 |
+
*
|
57 |
+
* @return mixed
|
58 |
+
*
|
59 |
+
* Add Option for tutor
|
60 |
+
*/
|
61 |
+
public function add_options($attr){
|
62 |
+
$attr['tutor_edd'] = array(
|
63 |
+
'label' => __( 'EDD', 'tutor-edd' ),
|
64 |
+
|
65 |
+
'sections' => array(
|
66 |
+
'general' => array(
|
67 |
+
'label' => __('General', 'tutor-edd'),
|
68 |
+
'desc' => __('Tutor Course Attachments Settings', 'tutor-edd'),
|
69 |
+
'fields' => array(
|
70 |
+
'enable_tutor_edd' => array(
|
71 |
+
'type' => 'checkbox',
|
72 |
+
'label' => __('Enable EDD', 'tutor'),
|
73 |
+
'desc' => __('This will enable sell your product via EDD', 'tutor'),
|
74 |
+
),
|
75 |
+
),
|
76 |
+
),
|
77 |
+
),
|
78 |
+
);
|
79 |
+
return $attr;
|
80 |
+
}
|
81 |
+
|
82 |
+
public function register_meta_box(){
|
83 |
+
add_meta_box( 'tutor-attached-edd-product', __( 'Add Product', 'tutor' ), array($this, 'course_add_product_metabox'), $this->course_post_type, 'advanced', 'high' );
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @param $post
|
88 |
+
* MetaBox for Lesson Modal Edit Mode
|
89 |
+
*/
|
90 |
+
public function course_add_product_metabox(){
|
91 |
+
include tutor()->path.'views/metabox/course-add-edd-product-metabox.php';
|
92 |
+
}
|
93 |
+
|
94 |
+
public function save_course_meta($post_ID){
|
95 |
+
$product_id = (int) tutor_utils()->avalue_dot('_tutor_course_product_id', $_POST);
|
96 |
+
if ($product_id){
|
97 |
+
update_post_meta($post_ID, '_tutor_course_product_id', $product_id);
|
98 |
+
update_post_meta($product_id, '_tutor_product', 'yes');
|
99 |
+
}else{
|
100 |
+
delete_post_meta($post_ID, '_tutor_course_product_id');
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
public function is_course_purchasable($bool, $course_id){
|
105 |
+
if ( ! tutor_utils()->has_edd()){
|
106 |
+
return false;
|
107 |
+
}
|
108 |
+
|
109 |
+
$course_id = tutor_utils()->get_post_id($course_id);
|
110 |
+
$has_product_id = get_post_meta($course_id, '_tutor_course_product_id', true);
|
111 |
+
if ($has_product_id){
|
112 |
+
return true;
|
113 |
+
}
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function get_tutor_course_price($price, $course_id){
|
118 |
+
$product_id = tutor_utils()->get_course_product_id($course_id);
|
119 |
+
|
120 |
+
return edd_price($product_id, false);
|
121 |
+
}
|
122 |
+
public function tutor_course_sell_by(){
|
123 |
+
return 'edd';
|
124 |
+
}
|
125 |
+
|
126 |
+
public function edd_update_payment_status($payment_id, $new_status, $old_status ){
|
127 |
+
if ($new_status !== 'publish'){
|
128 |
+
return;
|
129 |
+
}
|
130 |
+
|
131 |
+
$payment = new \EDD_Payment( $payment_id );
|
132 |
+
$cart_details = $payment->cart_details;
|
133 |
+
|
134 |
+
if ( is_array( $cart_details ) ) {
|
135 |
+
foreach ( $cart_details as $cart_index => $download ) {
|
136 |
+
|
137 |
+
$if_has_course = tutor_utils()->product_belongs_with_course($download['id']);
|
138 |
+
if ($if_has_course){
|
139 |
+
$course_id = $if_has_course->post_id;
|
140 |
+
$has_any_enrolled = tutor_utils()->has_any_enrolled($course_id);
|
141 |
+
if ( ! $has_any_enrolled){
|
142 |
+
tutor_utils()->do_enroll($course_id, $payment_id);
|
143 |
+
}
|
144 |
+
}
|
145 |
+
}
|
146 |
+
tutor_utils()->complete_course_enroll($payment_id);
|
147 |
+
}
|
148 |
+
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
}
|
classes/Utils.php
CHANGED
@@ -1813,6 +1813,18 @@ class Utils {
|
|
1813 |
return $query;
|
1814 |
}
|
1815 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1816 |
/**
|
1817 |
* @param int $course_id
|
1818 |
*
|
1813 |
return $query;
|
1814 |
}
|
1815 |
|
1816 |
+
/**
|
1817 |
+
* @return array|null|object
|
1818 |
+
*
|
1819 |
+
* Get EDD Products
|
1820 |
+
*/
|
1821 |
+
public function get_edd_products(){
|
1822 |
+
global $wpdb;
|
1823 |
+
$query = $wpdb->get_results("SELECT ID, post_title from {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'download' ");
|
1824 |
+
|
1825 |
+
return $query;
|
1826 |
+
}
|
1827 |
+
|
1828 |
/**
|
1829 |
* @param int $course_id
|
1830 |
*
|
classes/WooCommerce.php
ADDED
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: mhshohel
|
5 |
+
* Date: 1/10/18
|
6 |
+
* Time: 3:01 PM
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace TUTOR;
|
10 |
+
|
11 |
+
class WooCommerce extends Tutor_Base {
|
12 |
+
|
13 |
+
public function __construct() {
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
add_action('tutor_options_before_woocommerce', array($this, 'notice_before_option'));
|
17 |
+
|
18 |
+
//Add option settings
|
19 |
+
add_filter('tutor/options/attr', array($this, 'add_options'));
|
20 |
+
|
21 |
+
$course_sell = tutor_utils()->get_option('enable_course_sell_by_woocommerce');
|
22 |
+
if ( ! $course_sell){
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Is Course Purchasable
|
28 |
+
*/
|
29 |
+
add_filter('is_course_purchasable', array($this, 'is_course_purchasable'), 10, 2);
|
30 |
+
add_filter('get_tutor_course_price', array($this, 'get_tutor_course_price'), 10, 2);
|
31 |
+
add_filter('tutor_course_sell_by', array($this, 'tutor_course_sell_by'));
|
32 |
+
|
33 |
+
add_filter('product_type_options', array($this, 'add_tutor_type_in_wc_product'));
|
34 |
+
|
35 |
+
add_action( 'add_meta_boxes', array($this, 'register_meta_box') );
|
36 |
+
add_action('save_post_'.$this->course_post_type, array($this, 'save_course_meta'));
|
37 |
+
add_action('save_post_product', array($this, 'save_wc_product_meta'));
|
38 |
+
|
39 |
+
add_action('tutor_course/single/before/enroll', 'wc_print_notices');
|
40 |
+
|
41 |
+
add_action('woocommerce_new_order_item', array($this, 'course_placing_order'), 10, 3);
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Order Status Hook
|
46 |
+
*
|
47 |
+
* Remove course from active courses if an order is cancelled or refunded
|
48 |
+
*/
|
49 |
+
add_action( 'woocommerce_order_status_changed', array( $this, 'enrolled_courses_status_change' ), 10, 3 );
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
public function notice_before_option(){
|
54 |
+
$has_wc = tutor_utils()->has_wc();
|
55 |
+
if ($has_wc){
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
ob_start();
|
60 |
+
?>
|
61 |
+
<div class="tutor-notice-warning">
|
62 |
+
<p>
|
63 |
+
<?php _e(' Seems like you don’t have WooCommerce plugin installed on your site. In order to use this functionality, you need to have the
|
64 |
+
WooCommerce plugin installed. Get back on this page after installing the plugin and enable the following feature to start selling
|
65 |
+
courses with Tutor.', 'tutor'); ?>
|
66 |
+
</p>
|
67 |
+
<p><?php _e('This notice will disappear after activating <strong>WooCommerce</strong>', 'tutor'); ?></p>
|
68 |
+
</div>
|
69 |
+
<?php
|
70 |
+
echo ob_get_clean();
|
71 |
+
}
|
72 |
+
|
73 |
+
public function is_course_purchasable($bool, $course_id){
|
74 |
+
if ( ! tutor_utils()->has_wc()){
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
/*
|
78 |
+
$course_sell = tutor_utils()->get_option('enable_course_sell_by_woocommerce');
|
79 |
+
if ( ! $course_sell){
|
80 |
+
return false;
|
81 |
+
}*/
|
82 |
+
|
83 |
+
$course_id = tutor_utils()->get_post_id($course_id);
|
84 |
+
$has_product_id = get_post_meta($course_id, '_tutor_course_product_id', true);
|
85 |
+
if ($has_product_id){
|
86 |
+
return true;
|
87 |
+
}
|
88 |
+
return false;
|
89 |
+
}
|
90 |
+
|
91 |
+
public function get_tutor_course_price($price, $course_id){
|
92 |
+
|
93 |
+
$product_id = tutor_utils()->get_course_product_id($course_id);
|
94 |
+
$product = wc_get_product( $product_id );
|
95 |
+
|
96 |
+
if ($product) {
|
97 |
+
ob_start();
|
98 |
+
?>
|
99 |
+
<p class="price">
|
100 |
+
<?php echo $product->get_price_html(); ?>
|
101 |
+
</p>
|
102 |
+
<?php
|
103 |
+
return ob_get_clean();
|
104 |
+
}
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
public function tutor_course_sell_by(){
|
109 |
+
return 'woocommerce';
|
110 |
+
}
|
111 |
+
|
112 |
+
public function add_tutor_type_in_wc_product($types){
|
113 |
+
$types['tutor_product'] = array(
|
114 |
+
'id' => '_tutor_product',
|
115 |
+
'wrapper_class' => 'show_if_simple',
|
116 |
+
'label' => __( 'For Tutor', 'tutor' ),
|
117 |
+
'description' => __( 'This checkmark ensure that you will sell a specif course via this product.', 'tutor' ),
|
118 |
+
'default' => 'no',
|
119 |
+
);
|
120 |
+
|
121 |
+
return $types;
|
122 |
+
}
|
123 |
+
|
124 |
+
public function register_meta_box(){
|
125 |
+
add_meta_box( 'tutor-attach-product', __( 'Add Product', 'tutor' ), array($this, 'course_add_product_metabox'), $this->course_post_type, 'advanced', 'high' );
|
126 |
+
}
|
127 |
+
|
128 |
+
public function course_add_product_metabox(){
|
129 |
+
include tutor()->path.'views/metabox/course-add-product-metabox.php';
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @param $post_ID
|
134 |
+
*
|
135 |
+
* Save course meta for attaching product
|
136 |
+
*/
|
137 |
+
public function save_course_meta($post_ID){
|
138 |
+
$product_id = (int) tutor_utils()->avalue_dot('_tutor_course_product_id', $_POST);
|
139 |
+
if ($product_id){
|
140 |
+
update_post_meta($post_ID, '_tutor_course_product_id', $product_id);
|
141 |
+
//Mark product for woocommerce
|
142 |
+
update_post_meta($product_id, '_virtual', 'yes');
|
143 |
+
update_post_meta($product_id, '_tutor_product', 'yes');
|
144 |
+
}else{
|
145 |
+
delete_post_meta($post_ID, '_tutor_course_product_id');
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
|
151 |
+
public function save_wc_product_meta($post_ID){
|
152 |
+
$is_tutor_product = tutor_utils()->avalue_dot('_tutor_product', $_POST);
|
153 |
+
if ($is_tutor_product === 'on'){
|
154 |
+
update_post_meta($post_ID, '_tutor_product', 'yes');
|
155 |
+
}else{
|
156 |
+
delete_post_meta($post_ID, '_tutor_product');
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Do something after course order place
|
162 |
+
*/
|
163 |
+
|
164 |
+
public function course_placing_order( $item_id, $item, $order_id){
|
165 |
+
//$item = new \WC_Order_Item_Product($item);
|
166 |
+
|
167 |
+
$product_id = $item->get_product_id();
|
168 |
+
$if_has_course = tutor_utils()->product_belongs_with_course($product_id);
|
169 |
+
|
170 |
+
if ($if_has_course){
|
171 |
+
$course_id = $if_has_course->post_id;
|
172 |
+
tutor_utils()->do_enroll($course_id, $order_id);
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
/**
|
178 |
+
*
|
179 |
+
* Take enrolled course action based on order status change
|
180 |
+
*/
|
181 |
+
|
182 |
+
public function enrolled_courses_status_change($order_id, $status_from, $status_to){
|
183 |
+
if ( ! tutor_utils()->is_tutor_order($order_id)){
|
184 |
+
return;
|
185 |
+
}
|
186 |
+
global $wpdb;
|
187 |
+
|
188 |
+
$enrolled_ids_with_course = $this->get_course_enrolled_ids_by_order_id($order_id);
|
189 |
+
|
190 |
+
if ($enrolled_ids_with_course){
|
191 |
+
$enrolled_ids = wp_list_pluck($enrolled_ids_with_course, 'enrolled_id');
|
192 |
+
|
193 |
+
if (is_array($enrolled_ids) && count($enrolled_ids)){
|
194 |
+
foreach ($enrolled_ids as $enrolled_id){
|
195 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => $status_to ), array( 'ID' => $enrolled_id ) );
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* @param $order_id
|
203 |
+
*
|
204 |
+
* @return array|bool
|
205 |
+
*/
|
206 |
+
public function get_course_enrolled_ids_by_order_id($order_id){
|
207 |
+
global $wpdb;
|
208 |
+
//Getting all of courses ids within this order
|
209 |
+
|
210 |
+
$courses_ids = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE post_id = {$order_id} AND meta_key LIKE '_tutor_order_for_course_id_%' ");
|
211 |
+
|
212 |
+
if (is_array($courses_ids) && count($courses_ids)){
|
213 |
+
$course_enrolled_by_order = array();
|
214 |
+
foreach ($courses_ids as $courses_id){
|
215 |
+
$course_id = str_replace('_tutor_order_for_course_id_', '',$courses_id->meta_key);
|
216 |
+
//array(order_id => array('course_id' => $course_id, 'enrolled_id' => enrolled_id))
|
217 |
+
$course_enrolled_by_order[$courses_id->post_id] = array('course_id' => $course_id, 'enrolled_id' => $courses_id->meta_value);
|
218 |
+
}
|
219 |
+
return $course_enrolled_by_order;
|
220 |
+
}
|
221 |
+
return false;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Remove course
|
226 |
+
*
|
227 |
+
* TODO: right now it's unused
|
228 |
+
*/
|
229 |
+
public function remove_active_course($order_id){
|
230 |
+
global $wpdb;
|
231 |
+
//Getting all of courses ids within this order
|
232 |
+
|
233 |
+
$courses_ids = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE post_id = {$order_id} meta_key LIKE '_tutor_order_for_course_id_%' ");
|
234 |
+
}
|
235 |
+
|
236 |
+
|
237 |
+
/**
|
238 |
+
* @param $attr
|
239 |
+
*
|
240 |
+
* @return mixed
|
241 |
+
*
|
242 |
+
* Add option for WooCommerce settings
|
243 |
+
*/
|
244 |
+
public function add_options($attr){
|
245 |
+
|
246 |
+
$attr['woocommerce'] = array(
|
247 |
+
'label' => __( 'WooCommerce', 'tutor' ),
|
248 |
+
|
249 |
+
'sections' => array(
|
250 |
+
'general' => array(
|
251 |
+
'label' => __('General', 'tutor'),
|
252 |
+
'desc' => __('WooCommerce Settings', 'tutor'),
|
253 |
+
'fields' => array(
|
254 |
+
'enable_course_sell_by_woocommerce' => array(
|
255 |
+
'type' => 'checkbox',
|
256 |
+
'label' => __('Enable / Disable', 'tutor'),
|
257 |
+
'label_title' => __('Enable WooComerce to sell course', 'tutor'),
|
258 |
+
'desc' => __('By integrating WooCommerce, you can sell your course', 'tutor'),
|
259 |
+
),
|
260 |
+
),
|
261 |
+
),
|
262 |
+
),
|
263 |
+
);
|
264 |
+
|
265 |
+
return $attr;
|
266 |
+
}
|
267 |
+
|
268 |
+
|
269 |
+
}
|
classes/init.php
CHANGED
@@ -33,6 +33,9 @@ class init{
|
|
33 |
private $theme_compatibility;
|
34 |
private $gutenberg;
|
35 |
|
|
|
|
|
|
|
36 |
function __construct() {
|
37 |
|
38 |
$this->path = plugin_dir_path(TUTOR_FILE);
|
@@ -71,6 +74,8 @@ class init{
|
|
71 |
$this->user = new User();
|
72 |
$this->theme_compatibility = new Theme_Compatibility();
|
73 |
$this->gutenberg = new Gutenberg();
|
|
|
|
|
74 |
|
75 |
do_action('tutor_loaded');
|
76 |
}
|
@@ -83,7 +88,7 @@ class init{
|
|
83 |
if ( ! class_exists($className)){
|
84 |
$className = preg_replace(
|
85 |
array('/([a-z])([A-Z])/', '/\\\/'),
|
86 |
-
array('$1
|
87 |
$className
|
88 |
);
|
89 |
|
33 |
private $theme_compatibility;
|
34 |
private $gutenberg;
|
35 |
|
36 |
+
private $woocommerce;
|
37 |
+
private $edd;
|
38 |
+
|
39 |
function __construct() {
|
40 |
|
41 |
$this->path = plugin_dir_path(TUTOR_FILE);
|
74 |
$this->user = new User();
|
75 |
$this->theme_compatibility = new Theme_Compatibility();
|
76 |
$this->gutenberg = new Gutenberg();
|
77 |
+
$this->woocommerce = new WooCommerce();
|
78 |
+
$this->edd = new TutorEDD();
|
79 |
|
80 |
do_action('tutor_loaded');
|
81 |
}
|
88 |
if ( ! class_exists($className)){
|
89 |
$className = preg_replace(
|
90 |
array('/([a-z])([A-Z])/', '/\\\/'),
|
91 |
+
array('$1$2', DIRECTORY_SEPARATOR),
|
92 |
$className
|
93 |
);
|
94 |
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: lms, education, wp-lms, education management system
|
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.1
|
7 |
Requires PHP: 5.4.0
|
8 |
-
Stable tag: 1.0.
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
@@ -183,6 +183,12 @@ This is an alpha version of Tutor, as bugs and issues expected, if you found any
|
|
183 |
|
184 |
== Changelog ==
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
= 1.0.7 - 22 March, 2019 =
|
187 |
|
188 |
* Added: Radio input type at options panel
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.1
|
7 |
Requires PHP: 5.4.0
|
8 |
+
Stable tag: 1.0.8
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
183 |
|
184 |
== Changelog ==
|
185 |
|
186 |
+
|
187 |
+
= 1.0.8 - 25 March, 2019 =
|
188 |
+
|
189 |
+
* Added: WooCommerce and EDD support to sell courses
|
190 |
+
|
191 |
+
|
192 |
= 1.0.7 - 22 March, 2019 =
|
193 |
|
194 |
* Added: Radio input type at options panel
|
tutor.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Tutor LMS
|
|
4 |
Plugin URI: http://https://themeum.com/tutor
|
5 |
Description: Tutor is a complete solution for creating a Learning Management System in WordPress way. It can help you to create small to large scale online education site very conveniently. Power features like report, certificate, course preview, private file sharing make Tutor a robust plugin for any educational institutes.
|
6 |
Author: Themeum
|
7 |
-
Version: 1.0.
|
8 |
Author URI: http://themeum.com
|
9 |
Requires at least: 4.5
|
10 |
Tested up to: 5.1
|
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) )
|
|
17 |
/**
|
18 |
* Defined the tutor main file
|
19 |
*/
|
20 |
-
define('TUTOR_VERSION', '1.0.
|
21 |
define('TUTOR_FILE', __FILE__);
|
22 |
|
23 |
|
4 |
Plugin URI: http://https://themeum.com/tutor
|
5 |
Description: Tutor is a complete solution for creating a Learning Management System in WordPress way. It can help you to create small to large scale online education site very conveniently. Power features like report, certificate, course preview, private file sharing make Tutor a robust plugin for any educational institutes.
|
6 |
Author: Themeum
|
7 |
+
Version: 1.0.8
|
8 |
Author URI: http://themeum.com
|
9 |
Requires at least: 4.5
|
10 |
Tested up to: 5.1
|
17 |
/**
|
18 |
* Defined the tutor main file
|
19 |
*/
|
20 |
+
define('TUTOR_VERSION', '1.0.8');
|
21 |
define('TUTOR_FILE', __FILE__);
|
22 |
|
23 |
|
views/metabox/course-add-edd-product-metabox.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Add product metabox
|
4 |
+
*
|
5 |
+
* @author Themeum
|
6 |
+
* @url https://themeum.com
|
7 |
+
*
|
8 |
+
* @since v.1.0.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
?>
|
12 |
+
|
13 |
+
<div class="tutor-option-field-row">
|
14 |
+
<div class="tutor-option-field-label">
|
15 |
+
<label for="">
|
16 |
+
<?php _e('Select product', 'tutor-edd'); ?> <br />
|
17 |
+
<p class="text-muted">(<?php _e('Only for if you sell course', 'tutor-edd'); ?>)</p>
|
18 |
+
</label>
|
19 |
+
</div>
|
20 |
+
<div class="tutor-option-field">
|
21 |
+
<?php
|
22 |
+
|
23 |
+
$products = tutor_utils()->get_edd_products();
|
24 |
+
$product_id = tutor_utils()->get_course_product_id();
|
25 |
+
?>
|
26 |
+
|
27 |
+
<select name="_tutor_course_product_id" class="tutor_select2" style="min-width: 300px;">
|
28 |
+
<option value=""><?php _e('Select a Product'); ?></option>
|
29 |
+
<?php
|
30 |
+
foreach ($products as $product){
|
31 |
+
echo "<option value='{$product->ID}' ".selected($product->ID, $product_id)." >{$product->post_title}</option>";
|
32 |
+
}
|
33 |
+
?>
|
34 |
+
|
35 |
+
</select>
|
36 |
+
|
37 |
+
<p class="desc">
|
38 |
+
<?php _e('Sell your product, process by EDD', 'tutor-edd'); ?>
|
39 |
+
</p>
|
40 |
+
</div>
|
41 |
+
</div>
|