edd-order-history-card.php
6 days ago
native-order-history-card.php
6 days ago
order-history.php
6 days ago
wc-order-history-card.php
6 days ago
order-history.php
117 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Order History Template for Billing |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Dashboard |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 4.0.0 |
| 10 | * |
| 11 | * These variables are inherited from parent template. |
| 12 | * template: tutor/templates/dashboard/account/billing.php |
| 13 | * |
| 14 | * @var int $user_id The user ID. |
| 15 | * @var int $offset The offset for pagination. |
| 16 | * @var int $item_per_page The number of items per page. |
| 17 | * @var string $order_filter The order filter. |
| 18 | * @var int $current_page The current page. |
| 19 | */ |
| 20 | |
| 21 | defined( 'ABSPATH' ) || exit; |
| 22 | |
| 23 | use Tutor\Components\Button; |
| 24 | use Tutor\Components\Constants\Size; |
| 25 | use Tutor\Components\Constants\Variant; |
| 26 | use Tutor\Components\DateFilter; |
| 27 | use Tutor\Components\DropdownFilter; |
| 28 | use Tutor\Components\EmptyState; |
| 29 | use Tutor\Components\Pagination; |
| 30 | use Tutor\Components\Sorting; |
| 31 | use TUTOR\Dashboard; |
| 32 | use Tutor\Ecommerce\Ecommerce; |
| 33 | use TUTOR\Input; |
| 34 | |
| 35 | $monetize_by = tutor_utils()->get_option( 'monetize_by' ); |
| 36 | if ( 'free' === $monetize_by ) { |
| 37 | EmptyState::make()->title( __( 'No Orders Found!', 'tutor' ) )->render(); |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | $start_date = Input::get( 'start_date' ); |
| 42 | $end_date = Input::get( 'end_date' ); |
| 43 | $selected_filter = Input::get( 'data', 'all' ); |
| 44 | |
| 45 | $args = array( |
| 46 | 'status' => $selected_filter, |
| 47 | 'start_date' => $start_date, |
| 48 | 'end_date' => $end_date, |
| 49 | 'limit' => $item_per_page, |
| 50 | 'offset' => $offset, |
| 51 | 'order' => $order_filter, |
| 52 | ); |
| 53 | |
| 54 | $response = tutor_utils()->get_orders_by_user_id( $user_id, $args ); |
| 55 | $orders = $response->results ?? array(); |
| 56 | $total_items = $response->total_count ?? 0; |
| 57 | |
| 58 | $status_options = apply_filters( 'tutor_order_history_status_options', array(), $selected_filter ); |
| 59 | ?> |
| 60 | |
| 61 | <div class="tutor-flex tutor-items-center tutor-justify-between tutor-px-6 tutor-py-5 tutor-border-b"> |
| 62 | <?php DropdownFilter::make()->options( $status_options )->render(); ?> |
| 63 | <div class="tutor-flex tutor-items-center tutor-gap-3"> |
| 64 | <?php |
| 65 | $query_params = array( 'data', 'order', 'start_date', 'end_date' ); |
| 66 | if ( Input::has_any( $query_params, Input::GET_REQUEST ) ) { |
| 67 | Button::make() |
| 68 | ->tag( 'a' ) |
| 69 | ->size( Size::X_SMALL ) |
| 70 | ->attr( 'href', Dashboard::get_account_page_url( 'billing' ) ) |
| 71 | ->attr( 'class', 'tutor-text-brand' ) |
| 72 | ->label( __( 'Clear all', 'tutor' ) ) |
| 73 | ->variant( Variant::LINK ) |
| 74 | ->render(); |
| 75 | } |
| 76 | |
| 77 | DateFilter::make() |
| 78 | ->type( DateFilter::TYPE_RANGE ) |
| 79 | ->placement( DateFilter::PLACEMENT_BOTTOM_END ) |
| 80 | ->trigger_size( Size::X_SMALL ) |
| 81 | ->hide_initial_label() |
| 82 | ->render(); |
| 83 | |
| 84 | Sorting::make()->size( Size::X_SMALL )->order( $order_filter )->render(); |
| 85 | ?> |
| 86 | </div> |
| 87 | </div> |
| 88 | |
| 89 | <?php |
| 90 | if ( empty( $orders ) ) : |
| 91 | EmptyState::make() |
| 92 | ->title( 'No Orders Found!' ) |
| 93 | ->icon( tutor_utils()->get_themed_svg( 'images/illustrations/order-empty.svg' ) ) |
| 94 | ->render(); |
| 95 | else : |
| 96 | ?> |
| 97 | <div class="tutor-flex tutor-flex-column tutor-order-history"> |
| 98 | <?php |
| 99 | $default_card_template = Ecommerce::MONETIZE_BY === $monetize_by ? tutor_get_template( 'dashboard.account.billing.native-order-history-card' ) : ''; |
| 100 | $order_history_card_template = apply_filters( 'tutor_order_history_card_template', $default_card_template ); |
| 101 | foreach ( $orders as $order_data ) : |
| 102 | if ( file_exists( $order_history_card_template ) ) { |
| 103 | tutor_load_template_from_custom_path( $order_history_card_template, array( 'order_data' => $order_data ), false ); |
| 104 | } |
| 105 | endforeach; |
| 106 | ?> |
| 107 | </div> |
| 108 | |
| 109 | <?php |
| 110 | Pagination::make() |
| 111 | ->attr( 'class', 'tutor-px-6 tutor-py-6 tutor-border-t' ) |
| 112 | ->current( $current_page ) |
| 113 | ->total( $total_items ) |
| 114 | ->limit( $item_per_page ) |
| 115 | ->render(); |
| 116 | endif; |
| 117 |