PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.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 4.1.7.3.2 4.2.0 4.2.1 All 138 releases
learnpress / inc / Shortcodes / class-lp-shortcode-checkout.php

class-lp-shortcode-checkout.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.8, at inc/Shortcodes/class-lp-shortcode-checkout.php

95 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Checkout Page Shortcode.
4 *
5 * @author ThimPress
6 * @category Shortcodes
7 * @package Learnpress/Shortcodes
8 * @version 3.0.0
9 * @extends LP_Abstract_Shortcode
10 */
11
12 use LearnPress\Helpers\Template;
13
14 defined( 'ABSPATH' ) || exit();
15
16 if ( ! class_exists( 'LP_Shortcode_Checkout' ) ) {
17
18 /**
19 * Class LP_Shortcode_Checkout
20 */
21 class LP_Shortcode_Checkout extends LP_Abstract_Shortcode {
22
23 /**
24 * LP_Checkout_Shortcode constructor.
25 *
26 * @param mixed $atts
27 */
28 public function __construct( $atts = '' ) {
29 parent::__construct( $atts );
30 }
31
32 /**
33 * Output form.
34 *
35 * @return string
36 */
37 public function output() {
38 /**
39 * @var WP $wp
40 */
41 global $wp;
42 wp_enqueue_style( 'learnpress' );
43
44 ob_start();
45 if ( isset( $wp->query_vars['lp-order-received'] ) ) {
46 $this->order_received( $wp->query_vars['lp-order-received'] );
47 } else {
48 $checkout_cart = LearnPress::instance()->get_cart();
49
50 echo '<div id="learn-press-checkout" class="lp-content-area">';
51
52 // Check cart has contents
53 if ( $checkout_cart->is_empty() ) {
54 Template::instance()->get_frontend_template( 'checkout/empty-cart.php' );
55 } else {
56 wp_enqueue_script( 'lp-checkout' );
57 $checkout_cart->calculate_totals();
58 Template::instance()->get_frontend_template( 'checkout/form.php' );
59 }
60
61 echo '</div>';
62 }
63
64 return ob_get_clean();
65 }
66
67 /**
68 * Output received order information.
69 *
70 * @param int $order_id
71 *
72 * @return void
73 */
74 private function order_received( int $order_id = 0 ) {
75 $order_id = absint( $order_id );
76 $order_key = LP_Request::get_param( 'key' );
77 $order_received = learn_press_get_order( $order_id );
78 if ( ! $order_received ) {
79 return;
80 }
81
82 if ( $order_received->is_trashed() || $order_received->get_order_key() !== $order_key ) {
83 return;
84 }
85
86 //LearnPress::instance()->session->remove( 'order_awaiting_payment' );
87 //LearnPress::instance()->cart->empty_cart();
88 //learn_press_print_messages();
89
90 Template::instance()->get_frontend_template( 'checkout/order-received.php', compact( 'order_received' ) );
91 }
92 }
93 }
94
95