billing-form-fields.php
1 year ago
billing.php
1 year ago
cart.php
1 year ago
checkout-details.php
1 year ago
checkout.php
1 year ago
order-placement-failed.php
1 year ago
order-placement-success.php
1 year ago
checkout-details.php
285 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Checkout info template |
| 4 | * |
| 5 | * @package Tutor\Views |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 3.0.0 |
| 9 | */ |
| 10 | |
| 11 | use Tutor\Ecommerce\CartController; |
| 12 | use Tutor\Ecommerce\CheckoutController; |
| 13 | use Tutor\Ecommerce\Settings; |
| 14 | use Tutor\Ecommerce\Tax; |
| 15 | use TUTOR\Input; |
| 16 | use Tutor\Models\CouponModel; |
| 17 | use Tutor\Models\OrderModel; |
| 18 | |
| 19 | |
| 20 | $coupon_model = new CouponModel(); |
| 21 | $cart_controller = new CartController( false ); |
| 22 | $checkout_controller = new CheckoutController( false ); |
| 23 | $get_cart = $cart_controller->get_cart_items(); |
| 24 | $courses = $get_cart['courses']; |
| 25 | $total_count = $courses['total_count']; |
| 26 | $course_list = $courses['results']; |
| 27 | |
| 28 | $plan_id = (int) Input::sanitize_request_data( 'plan' ); |
| 29 | $plan_info = apply_filters( 'tutor_checkout_plan_info', new stdClass(), $plan_id ); |
| 30 | |
| 31 | // Contains Course/Bundle/Plan ids. |
| 32 | $object_ids = array(); |
| 33 | $order_type = ( $plan_id && $plan_info ) |
| 34 | ? OrderModel::TYPE_SUBSCRIPTION |
| 35 | : OrderModel::TYPE_SINGLE_ORDER; |
| 36 | |
| 37 | $coupon_code = Input::sanitize_request_data( 'coupon_code', '' ); |
| 38 | $has_manual_coupon_code = ! empty( $coupon_code ); |
| 39 | $show_coupon_box = Settings::is_coupon_usage_enabled(); |
| 40 | |
| 41 | $is_tax_included_in_price = Tax::is_tax_included_in_price(); |
| 42 | $tax_rate = Tax::get_user_tax_rate( get_current_user_id() ); |
| 43 | ?> |
| 44 | |
| 45 | <div class="tutor-checkout-details"> |
| 46 | <div class="tutor-checkout-details-inner"> |
| 47 | <h5 class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-border-bottom tutor-pb-8"> |
| 48 | <?php esc_html_e( 'Order Details', 'tutor' ); ?> |
| 49 | </h5> |
| 50 | <div class="tutor-checkout-detail-item"> |
| 51 | <div class="tutor-checkout-courses"> |
| 52 | <?php |
| 53 | // Subscription plan checkout item. |
| 54 | if ( isset( $plan_info->plan_name, $plan_info->regular_price ) ) { |
| 55 | $checkout_data = $checkout_controller->prepare_checkout_items( $plan_info->id, $order_type, $coupon_code ); |
| 56 | $enrollment_fee = floatval( $plan_info->enrollment_fee ); |
| 57 | $show_coupon_box = $plan_info->in_sale_price ? false : true; |
| 58 | |
| 59 | $plan_course_id = apply_filters( 'tutor_subscription_course_by_plan', $plan_id ); |
| 60 | $plan_course = get_post( $plan_course_id ); |
| 61 | $plan_course_thumbnail = get_tutor_course_thumbnail_src( 'post-thumbnail', $plan_course_id ); |
| 62 | |
| 63 | /** |
| 64 | * Plan item details. |
| 65 | * User can purchase only one plan at a time. |
| 66 | */ |
| 67 | $item = $checkout_data->items[0]; |
| 68 | |
| 69 | array_push( $object_ids, $plan_info->id ); |
| 70 | ?> |
| 71 | <div class="tutor-checkout-course-item"> |
| 72 | <div class="tutor-checkout-course-plan-badge"> |
| 73 | <?php echo esc_html( $item->item_name ); ?> |
| 74 | </div> |
| 75 | <div class="tutor-checkout-course-content"> |
| 76 | <div class="tutor-d-flex tutor-flex-column tutor-gap-1"> |
| 77 | <div class="tutor-checkout-course-thumb-title"> |
| 78 | <img src="<?php echo esc_url( $plan_course_thumbnail ); ?>" alt="<?php echo esc_attr( $plan_course->post_title ); ?>" /> |
| 79 | <h6 class="tutor-checkout-course-title"> |
| 80 | <a href="<?php echo esc_url( get_the_permalink( $plan_course ) ); ?>"> |
| 81 | <?php echo esc_html( $plan_course->post_title ); ?> |
| 82 | </a> |
| 83 | </h6> |
| 84 | </div> |
| 85 | <?php if ( $item->is_coupon_applied ) : ?> |
| 86 | <div class="tutor-checkout-coupon-badge"> |
| 87 | <i class="tutor-icon-tag" area-hidden="true"></i> |
| 88 | <span><?php echo esc_html( $checkout_data->coupon_title ); ?></span> |
| 89 | </div> |
| 90 | <?php endif; ?> |
| 91 | </div> |
| 92 | |
| 93 | <div class="tutor-text-right"> |
| 94 | <div class="tutor-fw-bold"> |
| 95 | <?php tutor_print_formatted_price( $item->display_price ); ?> |
| 96 | </div> |
| 97 | <?php if ( $item->sale_price || $item->discount_price ) : ?> |
| 98 | <div class="tutor-checkout-discount-price"> |
| 99 | <?php tutor_print_formatted_price( $item->regular_price ); ?> |
| 100 | </div> |
| 101 | <?php endif; ?> |
| 102 | <div class="tutor-fs-7 tutor-color-hints"> |
| 103 | <?php |
| 104 | echo esc_html( |
| 105 | $plan_info->recurring_value > 1 |
| 106 | ? sprintf( |
| 107 | /* translators: %s: value, %s: name */ |
| 108 | __( '/%1$s %2$s', 'tutor-pro' ), |
| 109 | $plan_info->recurring_value, |
| 110 | $plan_info->recurring_interval . ( $plan_info->recurring_value > 1 ? 's' : '' ) |
| 111 | ) |
| 112 | : |
| 113 | sprintf( |
| 114 | /* translators: %s: recurring interval */ |
| 115 | __( '/%1$s', 'tutor-pro' ), |
| 116 | $plan_info->recurring_interval . ( $plan_info->recurring_value > 1 ? 's' : '' ) |
| 117 | ) |
| 118 | ); |
| 119 | ?> |
| 120 | </div> |
| 121 | </div> |
| 122 | </div> |
| 123 | <?php if ( $enrollment_fee > 0 ) : ?> |
| 124 | <div class="tutor-checkout-enrollment-fee"> |
| 125 | <div class="tutor-fs-6 tutor-color-black"> |
| 126 | <?php echo esc_html_e( 'Enrollment Fee', 'tutor' ); ?> |
| 127 | </div> |
| 128 | <div class="tutor-text-right"> |
| 129 | <div class="tutor-fw-bold"> |
| 130 | <?php tutor_print_formatted_price( $enrollment_fee ); ?> |
| 131 | </div> |
| 132 | </div> |
| 133 | </div> |
| 134 | <?php endif; ?> |
| 135 | </div> |
| 136 | <!-- end subscription plan checkout item --> |
| 137 | <?php |
| 138 | } else { |
| 139 | /** |
| 140 | * Course and bundle checkout items. |
| 141 | */ |
| 142 | if ( is_array( $course_list ) && count( $course_list ) ) : |
| 143 | $course_ids = array_column( $course_list, 'ID' ); |
| 144 | $checkout_data = $checkout_controller->prepare_checkout_items( $course_ids, $order_type, $coupon_code ); |
| 145 | ?> |
| 146 | <?php |
| 147 | foreach ( $checkout_data->items as $item ) : |
| 148 | $course = get_post( $item->item_id ); |
| 149 | $course_thumbnail = get_tutor_course_thumbnail_src( 'post-thumbnail', $course->ID ); |
| 150 | array_push( $object_ids, $item->item_id ); |
| 151 | ?> |
| 152 | <div class="tutor-checkout-course-item" data-course-id="<?php echo esc_attr( $item->item_id ); ?>"> |
| 153 | <?php if ( tutor()->has_pro && 'course-bundle' === $course->post_type ) : ?> |
| 154 | <div class="tutor-checkout-course-bundle-badge"> |
| 155 | <?php |
| 156 | $bundle_model = new \TutorPro\CourseBundle\Models\BundleModel(); |
| 157 | $bundle_course_ids = $bundle_model::get_bundle_course_ids( $course->ID ); |
| 158 | // translators: %d: Number of courses in the cart. |
| 159 | echo esc_html( sprintf( __( '%d Course bundle', 'tutor' ), count( $bundle_course_ids ) ) ); |
| 160 | ?> |
| 161 | </div> |
| 162 | <?php endif; ?> |
| 163 | <div class="tutor-checkout-course-content"> |
| 164 | <div class="tutor-d-flex tutor-flex-column tutor-gap-1"> |
| 165 | <div class="tutor-checkout-course-thumb-title"> |
| 166 | <img src="<?php echo esc_url( $course_thumbnail ); ?>" alt="<?php echo esc_attr( $course->post_title ); ?>" /> |
| 167 | <h6 class="tutor-checkout-course-title"> |
| 168 | <a href="<?php echo esc_url( get_the_permalink( $course ) ); ?>"> |
| 169 | <?php echo esc_html( $course->post_title ); ?> |
| 170 | </a> |
| 171 | </h6> |
| 172 | </div> |
| 173 | <div class="tutor-checkout-coupon-badge <?php echo esc_attr( $item->is_coupon_applied ? '' : 'tutor-d-none' ); ?>"> |
| 174 | <i class="tutor-icon-tag" area-hidden="true"></i> |
| 175 | <span><?php echo esc_html( $item->is_coupon_applied ? $checkout_data->coupon_title : '' ); ?></span> |
| 176 | </div> |
| 177 | </div> |
| 178 | <div class="tutor-text-right"> |
| 179 | <div class="tutor-fw-bold"> |
| 180 | <?php tutor_print_formatted_price( $item->display_price ); ?> |
| 181 | </div> |
| 182 | <?php if ( $item->sale_price || $item->discount_price ) : ?> |
| 183 | <div class="tutor-checkout-discount-price"> |
| 184 | <?php tutor_print_formatted_price( $item->regular_price ); ?> |
| 185 | </div> |
| 186 | <?php endif; ?> |
| 187 | </div> |
| 188 | </div> |
| 189 | </div> |
| 190 | <?php endforeach; ?> |
| 191 | <?php else : ?> |
| 192 | <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?> |
| 193 | <?php endif; ?> |
| 194 | <?php } ?> |
| 195 | </div> |
| 196 | </div> |
| 197 | |
| 198 | <div class="tutor-checkout-detail-item tutor-checkout-summary"> |
| 199 | <div class="tutor-checkout-summary-item"> |
| 200 | <div class="tutor-fw-medium"><?php esc_html_e( 'Subtotal', 'tutor' ); ?></div> |
| 201 | <div class="tutor-fw-bold"> |
| 202 | <?php tutor_print_formatted_price( $checkout_data->subtotal_price ); ?> |
| 203 | </div> |
| 204 | </div> |
| 205 | |
| 206 | <?php if ( $checkout_data->sale_discount > 0 ) : ?> |
| 207 | <div class="tutor-checkout-summary-item"> |
| 208 | <div><?php esc_html_e( 'Sale discount', 'tutor' ); ?></div> |
| 209 | <div class="tutor-fw-bold"> |
| 210 | - <?php tutor_print_formatted_price( $checkout_data->sale_discount ); ?> |
| 211 | </div> |
| 212 | </div> |
| 213 | <?php endif ?> |
| 214 | |
| 215 | <?php if ( $show_coupon_box && ! $checkout_data->is_coupon_applied ) : ?> |
| 216 | <div class="tutor-checkout-summary-item tutor-have-a-coupon"> |
| 217 | <div><?php esc_html_e( 'Have a coupon?', 'tutor' ); ?></div> |
| 218 | <button type="button" id="tutor-toggle-coupon-button" class="tutor-btn tutor-btn-link"> |
| 219 | <?php esc_html_e( 'Click here', 'tutor' ); ?> |
| 220 | </button> |
| 221 | </div> |
| 222 | <div class="tutor-apply-coupon-form tutor-d-none"> |
| 223 | <input type="text" name="coupon_code" |
| 224 | <?php if ( 'manual' === $checkout_data->coupon_type && $checkout_data->is_coupon_applied ) : ?> |
| 225 | value="<?php echo esc_attr( $coupon_code ); ?>" |
| 226 | <?php endif; ?> |
| 227 | placeholder="<?php esc_html_e( 'Add coupon code', 'tutor' ); ?>"> |
| 228 | <button type="button" id="tutor-apply-coupon-button" class="tutor-btn tutor-btn-secondary" data-object-ids="<?php echo esc_attr( implode( ',', $object_ids ) ); ?>"><?php esc_html_e( 'Apply', 'tutor' ); ?></button> |
| 229 | </div> |
| 230 | <?php endif; ?> |
| 231 | |
| 232 | <div class="tutor-checkout-summary-item tutor-checkout-coupon-wrapper <?php echo esc_attr( $checkout_data->is_coupon_applied ? '' : 'tutor-d-none' ); ?>"> |
| 233 | <div class="tutor-checkout-coupon-badge tutor-has-delete-button"> |
| 234 | <i class="tutor-icon-tag" area-hidden="true"></i> |
| 235 | <span><?php echo esc_html( $checkout_data->coupon_title ); ?></span> |
| 236 | |
| 237 | <?php if ( 'manual' === $checkout_data->coupon_type && $checkout_data->is_coupon_applied ) : ?> |
| 238 | <button type="button" id="tutor-checkout-remove-coupon" class="tutor-btn"> |
| 239 | <i class="tutor-icon-times" area-hidden="true"></i> |
| 240 | </button> |
| 241 | <?php endif; ?> |
| 242 | </div> |
| 243 | <div class="tutor-fw-bold tutor-discount-amount">-<?php tutor_print_formatted_price( $checkout_data->coupon_discount ); ?></div> |
| 244 | </div> |
| 245 | |
| 246 | <?php |
| 247 | if ( Tax::is_tax_configured() && $tax_rate > 0 && ! $is_tax_included_in_price ) : |
| 248 | ?> |
| 249 | <div class="tutor-checkout-summary-item"> |
| 250 | <div><?php esc_html_e( 'Tax', 'tutor' ); ?></div> |
| 251 | <div class="tutor-fw-bold"><?php tutor_print_formatted_price( $checkout_data->tax_amount ); ?></div> |
| 252 | </div> |
| 253 | <?php endif; ?> |
| 254 | </div> |
| 255 | |
| 256 | <div class="tutor-pt-12 tutor-pb-20"> |
| 257 | <div class="tutor-checkout-summary-item"> |
| 258 | <div class="tutor-fw-medium"><?php esc_html_e( 'Grand Total', 'tutor' ); ?></div> |
| 259 | <div class="tutor-fs-5 tutor-fw-bold tutor-checkout-grand-total"> |
| 260 | <?php tutor_print_formatted_price( $checkout_data->total_price ); ?> |
| 261 | </div> |
| 262 | </div> |
| 263 | <div class="tutor-checkout-summary-item"> |
| 264 | <div></div> |
| 265 | <?php |
| 266 | if ( Tax::is_tax_configured() && $tax_rate > 0 && $is_tax_included_in_price ) : |
| 267 | ?> |
| 268 | <div class="tutor-fs-7 tutor-color-muted"> |
| 269 | <?php |
| 270 | /* translators: %s: tax amount */ |
| 271 | echo esc_html( sprintf( __( '(Incl. Tax %s)', 'tutor' ), tutor_get_formatted_price( $checkout_data->tax_amount ) ) ); |
| 272 | ?> |
| 273 | </div> |
| 274 | <?php endif ?> |
| 275 | </div> |
| 276 | |
| 277 | <?php if ( 'manual' === $checkout_data->coupon_type && $checkout_data->is_coupon_applied ) : ?> |
| 278 | <input type="hidden" name="coupon_code" value="<?php echo esc_attr( $coupon_code ); ?>"> |
| 279 | <?php endif; ?> |
| 280 | <input type="hidden" name="object_ids" value="<?php echo esc_attr( implode( ',', $object_ids ) ); ?>"> |
| 281 | <input type="hidden" name="order_type" value="<?php echo esc_attr( $order_type ); ?>"> |
| 282 | </div> |
| 283 | </div> |
| 284 | </div> |
| 285 |