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
296 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_get_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 | |
| 62 | /** |
| 63 | * Plan item details. |
| 64 | * User can purchase only one plan at a time. |
| 65 | */ |
| 66 | $item = $checkout_data->items[0]; |
| 67 | |
| 68 | array_push( $object_ids, $plan_info->id ); |
| 69 | |
| 70 | $plan_url = get_the_permalink( $plan_course ); |
| 71 | if ( $plan_info->is_membership_plan ) { |
| 72 | $plan_url = $plan_info->pricing_page_url; |
| 73 | } |
| 74 | |
| 75 | $thumbnail_url = get_tutor_course_thumbnail_src( 'post-thumbnail', $plan_course_id ); |
| 76 | $plan_title = $plan_info->is_membership_plan ? $plan_info->plan_name : $plan_course->post_title; |
| 77 | |
| 78 | $badge_label = $item->item_name; |
| 79 | ?> |
| 80 | <div class="tutor-checkout-course-item"> |
| 81 | <?php if ( ! $plan_info->is_membership_plan ) { ?> |
| 82 | <div class="tutor-checkout-course-plan-badge"> |
| 83 | <?php echo esc_html( $badge_label ); ?> |
| 84 | </div> |
| 85 | <?php } ?> |
| 86 | <div class="tutor-checkout-course-content"> |
| 87 | <div class="tutor-d-flex tutor-flex-column tutor-gap-1"> |
| 88 | <div class="<?php echo esc_attr( $plan_info->is_membership_plan ? '' : 'tutor-checkout-course-thumb-title' ); ?>"> |
| 89 | <?php if ( ! $plan_info->is_membership_plan ) { ?> |
| 90 | <img src="<?php echo esc_url( $thumbnail_url ); ?>" alt="<?php echo esc_attr( $plan_title ); ?>" /> |
| 91 | <?php } ?> |
| 92 | <h6 class="tutor-checkout-course-title"> |
| 93 | <a href="<?php echo esc_url( $plan_url ); ?>"> <?php echo esc_html( $plan_title ); ?></a> |
| 94 | </h6> |
| 95 | </div> |
| 96 | <?php if ( $item->is_coupon_applied ) : ?> |
| 97 | <div class="tutor-checkout-coupon-badge"> |
| 98 | <i class="tutor-icon-tag" area-hidden="true"></i> |
| 99 | <span><?php echo esc_html( $checkout_data->coupon_title ); ?></span> |
| 100 | </div> |
| 101 | <?php endif; ?> |
| 102 | </div> |
| 103 | |
| 104 | <div class="tutor-text-right"> |
| 105 | <div class="tutor-fw-bold"> |
| 106 | <?php tutor_print_formatted_price( $item->display_price ); ?> |
| 107 | </div> |
| 108 | <?php if ( $item->sale_price || $item->discount_price ) : ?> |
| 109 | <div class="tutor-checkout-discount-price"> |
| 110 | <?php tutor_print_formatted_price( $item->regular_price ); ?> |
| 111 | </div> |
| 112 | <?php endif; ?> |
| 113 | <div class="tutor-fs-7 tutor-color-hints"> |
| 114 | <?php |
| 115 | echo esc_html( |
| 116 | $plan_info->recurring_value > 1 |
| 117 | ? sprintf( |
| 118 | /* translators: %s: value, %s: name */ |
| 119 | __( '/%1$s %2$s', 'tutor-pro' ), |
| 120 | $plan_info->recurring_value, |
| 121 | $plan_info->recurring_interval . ( $plan_info->recurring_value > 1 ? 's' : '' ) |
| 122 | ) |
| 123 | : |
| 124 | sprintf( |
| 125 | /* translators: %s: recurring interval */ |
| 126 | __( '/%1$s', 'tutor-pro' ), |
| 127 | $plan_info->recurring_interval . ( $plan_info->recurring_value > 1 ? 's' : '' ) |
| 128 | ) |
| 129 | ); |
| 130 | ?> |
| 131 | </div> |
| 132 | </div> |
| 133 | </div> |
| 134 | <?php if ( $enrollment_fee > 0 ) : ?> |
| 135 | <div class="tutor-checkout-enrollment-fee"> |
| 136 | <div class="tutor-fs-6 tutor-color-black"> |
| 137 | <?php echo esc_html_e( 'Enrollment Fee', 'tutor' ); ?> |
| 138 | </div> |
| 139 | <div class="tutor-text-right"> |
| 140 | <div class="tutor-fw-bold"> |
| 141 | <?php tutor_print_formatted_price( $enrollment_fee ); ?> |
| 142 | </div> |
| 143 | </div> |
| 144 | </div> |
| 145 | <?php endif; ?> |
| 146 | </div> |
| 147 | <!-- end subscription plan checkout item --> |
| 148 | <?php |
| 149 | } else { |
| 150 | /** |
| 151 | * Course and bundle checkout items. |
| 152 | */ |
| 153 | if ( is_array( $course_list ) && count( $course_list ) ) : |
| 154 | $course_ids = array_column( $course_list, 'ID' ); |
| 155 | $checkout_data = $checkout_controller->prepare_checkout_items( $course_ids, $order_type, $coupon_code ); |
| 156 | ?> |
| 157 | <?php |
| 158 | foreach ( $checkout_data->items as $item ) : |
| 159 | $course = get_post( $item->item_id ); |
| 160 | $course_thumbnail = get_tutor_course_thumbnail_src( 'post-thumbnail', $course->ID ); |
| 161 | array_push( $object_ids, $item->item_id ); |
| 162 | ?> |
| 163 | <div class="tutor-checkout-course-item" data-course-id="<?php echo esc_attr( $item->item_id ); ?>"> |
| 164 | <?php if ( tutor()->has_pro && 'course-bundle' === $course->post_type ) : ?> |
| 165 | <div class="tutor-checkout-course-bundle-badge"> |
| 166 | <?php |
| 167 | $bundle_model = new \TutorPro\CourseBundle\Models\BundleModel(); |
| 168 | $bundle_course_ids = $bundle_model::get_bundle_course_ids( $course->ID ); |
| 169 | // translators: %d: Number of courses in the cart. |
| 170 | echo esc_html( sprintf( __( '%d Course bundle', 'tutor' ), count( $bundle_course_ids ) ) ); |
| 171 | ?> |
| 172 | </div> |
| 173 | <?php endif; ?> |
| 174 | <div class="tutor-checkout-course-content"> |
| 175 | <div class="tutor-d-flex tutor-flex-column tutor-gap-1"> |
| 176 | <div class="tutor-checkout-course-thumb-title"> |
| 177 | <img src="<?php echo esc_url( $course_thumbnail ); ?>" alt="<?php echo esc_attr( $course->post_title ); ?>" /> |
| 178 | <h6 class="tutor-checkout-course-title"> |
| 179 | <a href="<?php echo esc_url( get_the_permalink( $course ) ); ?>"> |
| 180 | <?php echo esc_html( $course->post_title ); ?> |
| 181 | </a> |
| 182 | </h6> |
| 183 | </div> |
| 184 | <div class="tutor-checkout-coupon-badge <?php echo esc_attr( $item->is_coupon_applied ? '' : 'tutor-d-none' ); ?>"> |
| 185 | <i class="tutor-icon-tag" area-hidden="true"></i> |
| 186 | <span><?php echo esc_html( $item->is_coupon_applied ? $checkout_data->coupon_title : '' ); ?></span> |
| 187 | </div> |
| 188 | </div> |
| 189 | <div class="tutor-text-right"> |
| 190 | <div class="tutor-fw-bold"> |
| 191 | <?php tutor_print_formatted_price( $item->display_price ); ?> |
| 192 | </div> |
| 193 | <?php if ( $item->sale_price || $item->discount_price ) : ?> |
| 194 | <div class="tutor-checkout-discount-price"> |
| 195 | <?php tutor_print_formatted_price( $item->regular_price ); ?> |
| 196 | </div> |
| 197 | <?php endif; ?> |
| 198 | </div> |
| 199 | </div> |
| 200 | </div> |
| 201 | <?php endforeach; ?> |
| 202 | <?php else : ?> |
| 203 | <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?> |
| 204 | <?php endif; ?> |
| 205 | <?php } ?> |
| 206 | </div> |
| 207 | </div> |
| 208 | |
| 209 | <div class="tutor-checkout-detail-item tutor-checkout-summary"> |
| 210 | <div class="tutor-checkout-summary-item"> |
| 211 | <div class="tutor-fw-medium"><?php esc_html_e( 'Subtotal', 'tutor' ); ?></div> |
| 212 | <div class="tutor-fw-bold"> |
| 213 | <?php tutor_print_formatted_price( $checkout_data->subtotal_price ); ?> |
| 214 | </div> |
| 215 | </div> |
| 216 | |
| 217 | <?php if ( $checkout_data->sale_discount > 0 ) : ?> |
| 218 | <div class="tutor-checkout-summary-item"> |
| 219 | <div><?php esc_html_e( 'Sale discount', 'tutor' ); ?></div> |
| 220 | <div class="tutor-fw-bold"> |
| 221 | - <?php tutor_print_formatted_price( $checkout_data->sale_discount ); ?> |
| 222 | </div> |
| 223 | </div> |
| 224 | <?php endif ?> |
| 225 | |
| 226 | <?php if ( $show_coupon_box && ! $checkout_data->is_coupon_applied ) : ?> |
| 227 | <div class="tutor-checkout-summary-item tutor-have-a-coupon"> |
| 228 | <div><?php esc_html_e( 'Have a coupon?', 'tutor' ); ?></div> |
| 229 | <button type="button" id="tutor-toggle-coupon-button" class="tutor-btn tutor-btn-link"> |
| 230 | <?php esc_html_e( 'Click here', 'tutor' ); ?> |
| 231 | </button> |
| 232 | </div> |
| 233 | <div class="tutor-apply-coupon-form tutor-d-none"> |
| 234 | <input type="text" name="coupon_code" |
| 235 | <?php if ( 'manual' === $checkout_data->coupon_type && $checkout_data->is_coupon_applied ) : ?> |
| 236 | value="<?php echo esc_attr( $coupon_code ); ?>" |
| 237 | <?php endif; ?> |
| 238 | placeholder="<?php esc_html_e( 'Add coupon code', 'tutor' ); ?>"> |
| 239 | <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> |
| 240 | </div> |
| 241 | <?php endif; ?> |
| 242 | |
| 243 | <div class="tutor-checkout-summary-item tutor-checkout-coupon-wrapper <?php echo esc_attr( $checkout_data->is_coupon_applied ? '' : 'tutor-d-none' ); ?>"> |
| 244 | <div class="tutor-checkout-coupon-badge tutor-has-delete-button"> |
| 245 | <i class="tutor-icon-tag" area-hidden="true"></i> |
| 246 | <span><?php echo esc_html( $checkout_data->coupon_title ); ?></span> |
| 247 | |
| 248 | <?php if ( 'manual' === $checkout_data->coupon_type && $checkout_data->is_coupon_applied ) : ?> |
| 249 | <button type="button" id="tutor-checkout-remove-coupon" class="tutor-btn"> |
| 250 | <i class="tutor-icon-times" area-hidden="true"></i> |
| 251 | </button> |
| 252 | <?php endif; ?> |
| 253 | </div> |
| 254 | <div class="tutor-fw-bold tutor-discount-amount">-<?php tutor_print_formatted_price( $checkout_data->coupon_discount ); ?></div> |
| 255 | </div> |
| 256 | |
| 257 | <?php |
| 258 | if ( Tax::is_tax_configured() && $tax_rate > 0 && ! $is_tax_included_in_price ) : |
| 259 | ?> |
| 260 | <div class="tutor-checkout-summary-item"> |
| 261 | <div><?php esc_html_e( 'Tax', 'tutor' ); ?></div> |
| 262 | <div class="tutor-fw-bold"><?php tutor_print_formatted_price( $checkout_data->tax_amount ); ?></div> |
| 263 | </div> |
| 264 | <?php endif; ?> |
| 265 | </div> |
| 266 | |
| 267 | <div class="tutor-pt-12 tutor-pb-20"> |
| 268 | <div class="tutor-checkout-summary-item"> |
| 269 | <div class="tutor-fw-medium"><?php esc_html_e( 'Grand Total', 'tutor' ); ?></div> |
| 270 | <div class="tutor-fs-5 tutor-fw-bold tutor-checkout-grand-total"> |
| 271 | <?php tutor_print_formatted_price( $checkout_data->total_price ); ?> |
| 272 | </div> |
| 273 | </div> |
| 274 | <div class="tutor-checkout-summary-item"> |
| 275 | <div></div> |
| 276 | <?php |
| 277 | if ( Tax::is_tax_configured() && $tax_rate > 0 && $is_tax_included_in_price ) : |
| 278 | ?> |
| 279 | <div class="tutor-fs-7 tutor-color-muted"> |
| 280 | <?php |
| 281 | /* translators: %s: tax amount */ |
| 282 | echo esc_html( sprintf( __( '(Incl. Tax %s)', 'tutor' ), tutor_get_formatted_price( $checkout_data->tax_amount ) ) ); |
| 283 | ?> |
| 284 | </div> |
| 285 | <?php endif ?> |
| 286 | </div> |
| 287 | |
| 288 | <?php if ( 'manual' === $checkout_data->coupon_type && $checkout_data->is_coupon_applied ) : ?> |
| 289 | <input type="hidden" name="coupon_code" value="<?php echo esc_attr( $coupon_code ); ?>"> |
| 290 | <?php endif; ?> |
| 291 | <input type="hidden" name="object_ids" value="<?php echo esc_attr( implode( ',', $object_ids ) ); ?>"> |
| 292 | <input type="hidden" name="order_type" value="<?php echo esc_attr( $order_type ); ?>"> |
| 293 | </div> |
| 294 | </div> |
| 295 | </div> |
| 296 |