Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions classes/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public static function get_account_pages() {
'url' => self::get_account_page_url( 'reviews' ),
'template' => tutor_get_template( 'dashboard.account.reviews' ),
),
'billing' => array(
'title' => esc_html__( 'Billing', 'tutor' ),
'icon' => Icon::BILLING,
'icon_active' => Icon::BILLING,
'url' => self::get_account_page_url( 'billing' ),
'template' => tutor_get_template( 'dashboard.account.billing' ),
),
'settings' => array(
'title' => esc_html__( 'Settings', 'tutor' ),
'icon' => Icon::SETTING,
Expand Down
9 changes: 6 additions & 3 deletions classes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -6318,21 +6318,24 @@ public function remove_instructor_role( $instructor_id = 0 ) {
* Get purchase history by customer id
*
* @since 1.0.0
* @since 4.0.0 param $order added.
*
* @param integer $user_id user id.
* @param string $period period.
* @param string $start_date start date.
* @param string $end_date end date.
* @param string $offset offset.
* @param string $per_page per page.
* @param string $order order.
*
* @return mixed
*/
public function get_orders_by_user_id( $user_id = 0, $period = '', $start_date = '', $end_date = '', $offset = '', $per_page = '' ) {
public function get_orders_by_user_id( $user_id = 0, $period = '', $start_date = '', $end_date = '', $offset = '', $per_page = '', $order = 'DESC' ) {
global $wpdb;

$user_id = $this->get_user_id( $user_id );
$monetize_by = $this->get_option( 'monetize_by' );
$order = QueryHelper::get_valid_sort_order( $order );

$post_type = '';
$user_meta = '';
Expand Down Expand Up @@ -6381,7 +6384,7 @@ public function get_orders_by_user_id( $user_id = 0, $period = '', $start_date =
WHERE orders.type = %s
AND orders.customer_id = %d
{$period_query}
ORDER BY orders.id DESC
ORDER BY orders.id {$order}
{$offset_limit_query}",
$post_type,
$user_id
Expand All @@ -6401,7 +6404,7 @@ public function get_orders_by_user_id( $user_id = 0, $period = '', $start_date =
WHERE post_type = %s
AND customer.meta_value = %d
{$period_query}
ORDER BY {$wpdb->posts}.id DESC
ORDER BY {$wpdb->posts}.id {$order}
{$offset_limit_query}
",
$post_type,
Expand Down
15 changes: 0 additions & 15 deletions components/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,6 @@ public function circle() {
return $this;
}

/**
* Set custom HTML attribute.
*
* @since 4.0.0
*
* @param string $key Attribute name.
* @param string $value Attribute value.
*
* @return $this
*/
public function attr( $key, $value ) {
$this->attributes[ $key ] = esc_attr( $value );
return $this;
}

/**
* Set the SVG icon for the badge.
*
Expand Down
19 changes: 17 additions & 2 deletions components/BaseComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,28 @@ public static function make() {
*
* @param array $attrs Key–value pairs of HTML attributes.
*
* @return self
* @return static
*/
public function attrs( array $attrs ): self {
public function attrs( array $attrs ) {
$this->attributes = array_merge( $this->attributes, $attrs );
return $this;
}

/**
* Set a custom HTML attribute.
*
* @since 4.0.0
*
* @param string $key Attribute name.
* @param string $value Attribute value.
*
* @return static
*/
public function attr( $key, $value ) {
$this->attributes[ $key ] = $value;
return $this;
}

/**
* Compile the stored attributes into an HTML string.
*
Expand Down
15 changes: 0 additions & 15 deletions components/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,6 @@ public function variant( $variant ) {
return $this;
}

/**
* Set custom HTML attribute.
*
* @since 4.0.0
*
* @param string $key Attribute name.
* @param string $value Attribute value.
*
* @return $this
*/
public function attr( $key, $value ) {
$this->attributes[ $key ] = esc_attr( $value );
return $this;
}

/**
* Set the SVG icon for the button.
*
Expand Down
15 changes: 0 additions & 15 deletions components/InputField.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,21 +543,6 @@ public function required( $required = true ) {
return $this;
}

/**
* Set attributes.
*
* @since 4.0.0
*
* @param string $key Attribute key.
* @param string $value Attribute value.
*
* @return $this
*/
public function attr( $key, $value ) {
$this->attributes[ $key ] = $value;
return $this;
}

/**
* Set disabled state.
*
Expand Down
16 changes: 0 additions & 16 deletions components/Nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,6 @@ public function variant( $variant = Variant::PRIMARY ): self {
return $this;
}

/**
* Set custom HTML attribute.
*
* @since 4.0.0
*
* @param string $key Attribute name.
* @param string $value Attribute value.
*
* @return $this
*/
public function attr( $key, $value ) {
$this->attributes[ $key ] = esc_attr( $value );
return $this;
}


/**
* Set the nav size.
*
Expand Down
12 changes: 11 additions & 1 deletion components/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,19 @@ protected function get_paginated_links_list() {
* @return string
*/
public function get(): string {
if ( $this->pagination_total <= $this->pagination_limit ) {
return '';
}

$pagination_links = $this->get_paginated_links_list() ?? array();
$pagination_info = $this->render_pagination_info() ?? '';
$links = '';

$classes = array( 'tutor-pagination' );
if ( isset( $this->attributes['class'] ) ) {
$classes[] = $this->attributes['class'];
}

if ( count( $pagination_links ) ) {
foreach ( $pagination_links as $link ) {
$link = str_replace( 'page-numbers dots', 'tutor-pagination-ellipsis', $link );
Expand All @@ -258,12 +267,13 @@ public function get(): string {
}

return sprintf(
'<nav class="tutor-pagination" role="navigation" aria-label="Pagination Navigation">
'<nav class="%s" role="navigation" aria-label="Pagination Navigation">
%s
<ul class="tutor-pagination-list">
%s
</ul>
</nav>',
esc_attr( implode( ' ', $classes ) ),
$pagination_info,
$links
);
Expand Down
17 changes: 14 additions & 3 deletions ecommerce/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,11 +715,14 @@ public function prepare_bulk_actions(): array {
/**
* Available tabs that will visible on the right side of page navbar
*
* @return array
*
* @since 3.0.0
* @since 4.0.0 param $context added.
*
* @param string $context context.
*
* @return array
*/
public function tabs_key_value(): array {
public function tabs_key_value( $context = '' ): array {
$url = apply_filters( 'tutor_data_tab_base_url', get_pagenum_link() );

$date = Input::get( 'date', '' );
Expand All @@ -734,6 +737,14 @@ public function tabs_key_value(): array {
$where['date(o.created_at_gmt)'] = tutor_get_formated_date( '', $date );
}

if ( 'dashboard' === $context ) {
$start_date = Input::get( 'start_date', '' );
$end_date = Input::get( 'end_date', '' );
if ( ! empty( $start_date ) && ! empty( $end_date ) ) {
$where['date(o.created_at_gmt)'] = array( 'BETWEEN', array( tutor_get_formated_date( '', $start_date ), tutor_get_formated_date( '', $end_date ) ) );
}
}

if ( ! empty( $payment_status ) ) {
$where['o.payment_status'] = $payment_status;
}
Expand Down
56 changes: 56 additions & 0 deletions helpers/ComponentHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Component Helper.
*
* @package Tutor\Helper
* @author Themeum <[email protected]>
* @link https://themeum.com
* @since 4.0.0
*/

namespace Tutor\Helpers;

use Tutor\Components\Badge;

/**
* Class ComponentHelper
*
* @since 4.0.0
*/
class ComponentHelper {

/**
* Order status badge
*
* @since 4.0.0
*
* @param string $status order status. It can be tutor or other monetization order status.
*
* @return void
*/
public static function order_status_badge( $status ) : void {
$badge_class = 'secondary';
switch ( $status ) {
case 'processing':
case 'pending':
case 'on-hold':
$badge_class = 'pending';
break;
case 'refunded':
case 'cancelled':
$badge_class = 'cancelled';
break;
case 'incomplete':
$badge_class = 'secondary';
break;
case 'completed':
$badge_class = 'completed';
break;
}

$label = tutor_utils()->translate_dynamic_text( $status );

Badge::make()->attr( 'class', 'tutor-badge-' . $badge_class )->circle()->label( $label )->render();

}
}
19 changes: 13 additions & 6 deletions models/OrderModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -988,21 +988,26 @@ public function get_order_count( $where = array(), string $search_term = '' ) {
* Get order of a user
*
* @since 3.0.0
* @since 4.0.0 params $order_status and $order added.
*
* @param string $time_period $time_period Sorting time period,
* supported time periods are: today, monthly & yearly.
* @param string $start_date $start_date For date range sorting.
* @param string $end_date $end_date For date range sorting.
* @param string $order_status $order_status Order status.
* @param int $user_id User id for fetching order list.
* @param int $limit Limit to fetch record.
* @param int $offset Offset to fetch record.
* @param string $order Order to fetch record.
*
* @throws \Exception Throw exception if database error occur.
*
* @return array
*/
public function get_user_orders( $time_period = null, $start_date = null, $end_date = null, int $user_id = 0, $limit = 10, int $offset = 0 ) {
$user_id = $user_id ? $user_id : get_current_user_id();
public function get_user_orders( $time_period = null, $start_date = null, $end_date = null, $order_status = '', int $user_id = 0, $limit = 10, int $offset = 0, $order = 'DESC' ) {
$user_id = tutor_utils()->get_user_id( $user_id );
$order = QueryHelper::get_valid_sort_order( $order );
$order_status = esc_sql( $order_status );

$response = array(
'results' => array(),
Expand All @@ -1011,8 +1016,9 @@ public function get_user_orders( $time_period = null, $start_date = null, $end_d

global $wpdb;

$time_period_clause = '';
$date_range_clause = '';
$time_period_clause = '';
$date_range_clause = '';
$order_status_clause = ( empty( $order_status ) || 'all' === $order_status ) ? '' : "AND o.order_status = '{$order_status}'";

if ( $start_date && $end_date ) {
$date_range_clause = $wpdb->prepare( 'AND DATE(created_at_gmt) BETWEEN %s AND %s', $start_date, $end_date );
Expand All @@ -1035,7 +1041,8 @@ public function get_user_orders( $time_period = null, $start_date = null, $end_d
WHERE o.user_id = %d
{$time_period_clause}
{$date_range_clause}
ORDER BY o.id DESC
{$order_status_clause}
ORDER BY o.id {$order}
LIMIT %d OFFSET %d
",
$user_id,
Expand Down Expand Up @@ -2126,7 +2133,7 @@ public static function pay_now_link( $order_id, $display = true ) {

$link =
sprintf(
'<a href="%s" class="tutor-btn tutor-btn-sm tutor-btn-outline-primary">
'<a href="%s" class="tutor-btn tutor-btn-link tutor-text-brand tutor-p-none tutor-min-h-fit">
%s
</a>',
esc_url( $checkout_url ),
Expand Down
Loading
Loading