| @@ -1,71 +1,86 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Class LP_Template_Checkout | |
| 5 | - * | |
| 6 | - * Groups templates related checkout page | |
| 7 | - * | |
| 8 | - * @since 3.x.x | |
| 9 | - */ | |
| 10 | -class LP_Template_Checkout extends LP_Abstract_Template { | |
| 11 | - | |
| 12 | - /** | |
| 13 | - * LP_Template_Checkout constructor. | |
| 14 | - */ | |
| 15 | - public function __construct() { | |
| 16 | - parent::__construct(); | |
| 17 | - } | |
| 18 | - | |
| 19 | - public function review_order() { | |
| 20 | - $cart = LearnPress::instance()->cart; | |
| 21 | - learn_press_get_template( 'checkout/review-order', compact( 'cart' ) ); | |
| 22 | - } | |
| 23 | - | |
| 24 | - public function payment() { | |
| 25 | - $available_gateways = LP_Gateways::instance()->get_available_payment_gateways(); | |
| 26 | - | |
| 27 | - learn_press_get_template( 'checkout/payment.php', array( 'available_gateways' => $available_gateways ) ); | |
| 28 | - } | |
| 29 | - | |
| 30 | - public function order_comment() { | |
| 31 | - learn_press_get_template( 'checkout/order-comment.php' ); | |
| 32 | - } | |
| 33 | - | |
| 34 | - public function account_logged_in() { | |
| 35 | - if ( ! is_user_logged_in() ) { | |
| 36 | - return; | |
| 37 | - } | |
| 38 | - | |
| 39 | - learn_press_get_template( 'checkout/account-logged-in' ); | |
| 40 | - } | |
| 41 | - | |
| 42 | - public function account_login() { | |
| 43 | - if ( is_user_logged_in() || ! LearnPress::instance()->checkout()->is_enable_login() ) { | |
| 44 | - return; | |
| 45 | - } | |
| 46 | - | |
| 47 | - learn_press_get_template( 'checkout/account-login' ); | |
| 48 | - } | |
| 49 | - | |
| 50 | - public function account_register() { | |
| 51 | - if ( is_user_logged_in() || ! LearnPress::instance()->checkout()->is_enable_register() ) { | |
| 52 | - return; | |
| 53 | - } | |
| 54 | - | |
| 55 | - learn_press_get_template( 'checkout/account-register' ); | |
| 56 | - } | |
| 57 | - | |
| 58 | - public function guest_checkout() { | |
| 59 | - if ( is_user_logged_in() || ! LearnPress::instance()->checkout()->is_enable_guest_checkout() ) { | |
| 60 | - return; | |
| 61 | - } | |
| 62 | - | |
| 63 | - learn_press_get_template( 'checkout/guest-checkout' ); | |
| 64 | - } | |
| 65 | - | |
| 66 | - public function terms() { | |
| 67 | - learn_press_get_template( 'checkout/term-conditions' ); | |
| 68 | - } | |
| 69 | -} | |
| 70 | - | |
| 71 | -return new LP_Template_Checkout(); | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Class LP_Template_Checkout | |
| 5 | + * | |
| 6 | + * Groups templates related checkout page | |
| 7 | + * | |
| 8 | + * @since 3.x.x | |
| 9 | + */ | |
| 10 | +class LP_Template_Checkout extends LP_Abstract_Template { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * LP_Template_Checkout constructor. | |
| 14 | + */ | |
| 15 | + public function __construct() { | |
| 16 | + parent::__construct(); | |
| 17 | + } | |
| 18 | + | |
| 19 | + public function review_order() { | |
| 20 | + $cart = LearnPress::instance()->cart; | |
| 21 | + learn_press_get_template( 'checkout/review-order', compact( 'cart' ) ); | |
| 22 | + } | |
| 23 | + | |
| 24 | + public function payment() { | |
| 25 | + $available_gateways = LP_Gateways::instance()->get_available_payment_gateways(); | |
| 26 | + | |
| 27 | + learn_press_get_template( 'checkout/payment.php', array( 'available_gateways' => $available_gateways ) ); | |
| 28 | + } | |
| 29 | + | |
| 30 | + public function order_comment() { | |
| 31 | + learn_press_get_template( 'checkout/order-comment.php' ); | |
| 32 | + } | |
| 33 | + | |
| 34 | + public function account_logged_in() { | |
| 35 | + if ( ! is_user_logged_in() ) { | |
| 36 | + return; | |
| 37 | + } | |
| 38 | + | |
| 39 | + learn_press_get_template( 'checkout/account-logged-in' ); | |
| 40 | + } | |
| 41 | + | |
| 42 | + public function account_login() { | |
| 43 | + $checkout = LearnPress::instance()->checkout(); | |
| 44 | + | |
| 45 | + if ( is_user_logged_in() | |
| 46 | + || ! $checkout->is_enable_login() | |
| 47 | + || ( $checkout->is_enable_guest_checkout() && ! isset( $_GET['is_form_login'] ) ) ) { | |
| 48 | + return; | |
| 49 | + } | |
| 50 | + | |
| 51 | + if ( isset( $_GET['is_form_register'] ) ) { | |
| 52 | + return; | |
| 53 | + } | |
| 54 | + | |
| 55 | + learn_press_get_template( 'checkout/account-login' ); | |
| 56 | + } | |
| 57 | + | |
| 58 | + public function account_register() { | |
| 59 | + if ( is_user_logged_in() | |
| 60 | + || ! LearnPress::instance()->checkout()->is_enable_register() | |
| 61 | + || isset( $_GET['is_form_login'] ) | |
| 62 | + || ! isset( $_GET['is_form_register'] ) ) { | |
| 63 | + return; | |
| 64 | + } | |
| 65 | + | |
| 66 | + learn_press_get_template( 'checkout/account-register' ); | |
| 67 | + } | |
| 68 | + | |
| 69 | + public function guest_checkout() { | |
| 70 | + $is_account_form = isset( $_GET['is_form_login'] ) || isset( $_GET['is_form_register'] ); | |
| 71 | + | |
| 72 | + if ( is_user_logged_in() | |
| 73 | + || ! LearnPress::instance()->checkout()->is_enable_guest_checkout() | |
| 74 | + || $is_account_form ) { | |
| 75 | + return; | |
| 76 | + } | |
| 77 | + | |
| 78 | + learn_press_get_template( 'checkout/guest-checkout' ); | |
| 79 | + } | |
| 80 | + | |
| 81 | + public function terms() { | |
| 82 | + learn_press_get_template( 'checkout/term-conditions' ); | |
| 83 | + } | |
| 84 | +} | |
| 85 | + | |
| 86 | +return new LP_Template_Checkout(); | |