PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9.1 4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 All 141 releases
← All changes | inc/cart/lp-cart-functions.php +20 -14 4.1.7 → 4.4.9 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * Return LP_Cart object instance
4 4 *
5 - * @return mixed
5 + * @return LP_Cart
6 6 */
7 -function learn_press_get_cart() {
8 - return LP()->cart;
7 +function learn_press_get_cart(): LP_Cart {
8 + return LearnPress::instance()->cart;
9 9 }
10 10
11 11 function learn_press_enable_cart() {
12 12 return apply_filters( 'learn-press/enable-cart', false );
@@ -17,9 +17,9 @@
17 17 *
18 18 * @return string
19 19 */
20 20 function learn_press_get_cart_description() {
21 - $items = LP()->cart->get_items();
21 + $items = LearnPress::instance()->cart->get_items();
22 22 $description = array();
23 23
24 24 if ( $items ) {
25 25 foreach ( $items as $item ) {
@@ -47,13 +47,18 @@
47 47 /**
48 48 * Return total of cart
49 49 *
50 50 * @return mixed
51 + * @deprecated 4.2.0
51 52 */
52 53 function learn_press_get_cart_total() {
53 - return LP()->cart->total;
54 + _deprecated_function( __FUNCTION__, '4.2.0' );
55 + return LearnPress::instance()->cart->total;
54 56 }
55 57
58 +/**
59 + * @deprecated 4.2.0
60 + */
56 61 function learn_press_clear_cart_after_payment() {
57 62 global $wp;
58 63
59 64 if ( ! empty( $wp->query_vars['lp-order-received'] ) ) {
@@ -62,32 +67,33 @@
62 67 $order = learn_press_get_order( $order_id );
63 68
64 69 if ( $order_id > 0 && $order ) {
65 70 if ( $order->order_key === $order_key ) {
66 - LP()->cart->empty_cart();
71 + LearnPress::instance()->cart->empty_cart();
67 72 }
68 73 }
69 74 }
70 75
71 - if ( ! is_null( LP()->session ) && LP()->session->order_awaiting_payment > 0 ) {
72 - $order = learn_press_get_order( LP()->session->order_awaiting_payment );
76 + if ( ! is_null( LearnPress::instance()->session ) && LearnPress::instance()->session->get( 'order_awaiting_payment' ) > 0 ) {
77 + $order = learn_press_get_order( LearnPress::instance()->session->get( 'order_awaiting_payment' ) );
73 78
74 79 if ( $order && $order->id > 0 ) {
75 80 if ( ! $order->has_status( array( 'failed', 'pending', 'cancelled' ) ) ) {
76 - LP()->cart->empty_cart();
77 - LP()->session->order_awaiting_payment = null;
81 + LearnPress::instance()->cart->empty_cart();
82 + LearnPress::instance()->session->remove( 'order_awaiting_payment' );
78 83 }
79 84 }
80 85 }
81 86 }
82 -add_action( 'get_header', 'learn_press_clear_cart_after_payment' );
87 +//add_action( 'get_header', 'learn_press_clear_cart_after_payment' );
83 88
84 89 /**
85 90 * @param LP_Cart $cart
86 91 *
87 92 * @return mixed
93 + * @deprecated 4.2.0
88 94 */
89 -function learn_press_custom_checkout_cart( $cart ) {
95 +/*function learn_press_custom_checkout_cart( $cart ) {
90 96 if ( empty( $_REQUEST['single-item'] ) ) {
91 97 return $cart;
92 98 }
93 99
@@ -99,6 +105,6 @@
99 105 $cart->add_to_cart( $item );
100 106 }
101 107
102 108 return $cart;
103 -}
104 -add_filter( 'learn_press_checkout_cart', 'learn_press_custom_checkout_cart' );
109 +}*/
110 +//add_filter( 'learn_press_checkout_cart', 'learn_press_custom_checkout_cart' );