Skip to content

Commit 612584c

Browse files
authored
Merge pull request #2299 from themeum/harun-v4
Order list functionality implemented under billing section
2 parents dc1a37c + 3070721 commit 612584c

File tree

16 files changed

+385
-77
lines changed

16 files changed

+385
-77
lines changed

classes/Dashboard.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ public static function get_account_pages() {
8383
'url' => self::get_account_page_url( 'reviews' ),
8484
'template' => tutor_get_template( 'dashboard.account.reviews' ),
8585
),
86+
'billing' => array(
87+
'title' => esc_html__( 'Billing', 'tutor' ),
88+
'icon' => Icon::BILLING,
89+
'icon_active' => Icon::BILLING,
90+
'url' => self::get_account_page_url( 'billing' ),
91+
'template' => tutor_get_template( 'dashboard.account.billing' ),
92+
),
8693
'settings' => array(
8794
'title' => esc_html__( 'Settings', 'tutor' ),
8895
'icon' => Icon::SETTING,

classes/Utils.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6318,21 +6318,24 @@ public function remove_instructor_role( $instructor_id = 0 ) {
63186318
* Get purchase history by customer id
63196319
*
63206320
* @since 1.0.0
6321+
* @since 4.0.0 param $order added.
63216322
*
63226323
* @param integer $user_id user id.
63236324
* @param string $period period.
63246325
* @param string $start_date start date.
63256326
* @param string $end_date end date.
63266327
* @param string $offset offset.
63276328
* @param string $per_page per page.
6329+
* @param string $order order.
63286330
*
63296331
* @return mixed
63306332
*/
6331-
public function get_orders_by_user_id( $user_id = 0, $period = '', $start_date = '', $end_date = '', $offset = '', $per_page = '' ) {
6333+
public function get_orders_by_user_id( $user_id = 0, $period = '', $start_date = '', $end_date = '', $offset = '', $per_page = '', $order = 'DESC' ) {
63326334
global $wpdb;
63336335

63346336
$user_id = $this->get_user_id( $user_id );
63356337
$monetize_by = $this->get_option( 'monetize_by' );
6338+
$order = QueryHelper::get_valid_sort_order( $order );
63366339

63376340
$post_type = '';
63386341
$user_meta = '';
@@ -6381,7 +6384,7 @@ public function get_orders_by_user_id( $user_id = 0, $period = '', $start_date =
63816384
WHERE orders.type = %s
63826385
AND orders.customer_id = %d
63836386
{$period_query}
6384-
ORDER BY orders.id DESC
6387+
ORDER BY orders.id {$order}
63856388
{$offset_limit_query}",
63866389
$post_type,
63876390
$user_id
@@ -6401,7 +6404,7 @@ public function get_orders_by_user_id( $user_id = 0, $period = '', $start_date =
64016404
WHERE post_type = %s
64026405
AND customer.meta_value = %d
64036406
{$period_query}
6404-
ORDER BY {$wpdb->posts}.id DESC
6407+
ORDER BY {$wpdb->posts}.id {$order}
64056408
{$offset_limit_query}
64066409
",
64076410
$post_type,

components/Badge.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,6 @@ public function circle() {
158158
return $this;
159159
}
160160

161-
/**
162-
* Set custom HTML attribute.
163-
*
164-
* @since 4.0.0
165-
*
166-
* @param string $key Attribute name.
167-
* @param string $value Attribute value.
168-
*
169-
* @return $this
170-
*/
171-
public function attr( $key, $value ) {
172-
$this->attributes[ $key ] = esc_attr( $value );
173-
return $this;
174-
}
175-
176161
/**
177162
* Set the SVG icon for the badge.
178163
*

components/BaseComponent.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,28 @@ public static function make() {
6969
*
7070
* @param array $attrs Key–value pairs of HTML attributes.
7171
*
72-
* @return self
72+
* @return static
7373
*/
74-
public function attrs( array $attrs ): self {
74+
public function attrs( array $attrs ) {
7575
$this->attributes = array_merge( $this->attributes, $attrs );
7676
return $this;
7777
}
7878

79+
/**
80+
* Set a custom HTML attribute.
81+
*
82+
* @since 4.0.0
83+
*
84+
* @param string $key Attribute name.
85+
* @param string $value Attribute value.
86+
*
87+
* @return static
88+
*/
89+
public function attr( $key, $value ) {
90+
$this->attributes[ $key ] = $value;
91+
return $this;
92+
}
93+
7994
/**
8095
* Compile the stored attributes into an HTML string.
8196
*

components/Button.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,6 @@ public function variant( $variant ) {
181181
return $this;
182182
}
183183

184-
/**
185-
* Set custom HTML attribute.
186-
*
187-
* @since 4.0.0
188-
*
189-
* @param string $key Attribute name.
190-
* @param string $value Attribute value.
191-
*
192-
* @return $this
193-
*/
194-
public function attr( $key, $value ) {
195-
$this->attributes[ $key ] = esc_attr( $value );
196-
return $this;
197-
}
198-
199184
/**
200185
* Set the SVG icon for the button.
201186
*

components/InputField.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -543,21 +543,6 @@ public function required( $required = true ) {
543543
return $this;
544544
}
545545

546-
/**
547-
* Set attributes.
548-
*
549-
* @since 4.0.0
550-
*
551-
* @param string $key Attribute key.
552-
* @param string $value Attribute value.
553-
*
554-
* @return $this
555-
*/
556-
public function attr( $key, $value ) {
557-
$this->attributes[ $key ] = $value;
558-
return $this;
559-
}
560-
561546
/**
562547
* Set disabled state.
563548
*

components/Nav.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,6 @@ public function variant( $variant = Variant::PRIMARY ): self {
113113
return $this;
114114
}
115115

116-
/**
117-
* Set custom HTML attribute.
118-
*
119-
* @since 4.0.0
120-
*
121-
* @param string $key Attribute name.
122-
* @param string $value Attribute value.
123-
*
124-
* @return $this
125-
*/
126-
public function attr( $key, $value ) {
127-
$this->attributes[ $key ] = esc_attr( $value );
128-
return $this;
129-
}
130-
131-
132116
/**
133117
* Set the nav size.
134118
*

components/Pagination.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,19 @@ protected function get_paginated_links_list() {
240240
* @return string
241241
*/
242242
public function get(): string {
243+
if ( $this->pagination_total <= $this->pagination_limit ) {
244+
return '';
245+
}
246+
243247
$pagination_links = $this->get_paginated_links_list() ?? array();
244248
$pagination_info = $this->render_pagination_info() ?? '';
245249
$links = '';
246250

251+
$classes = array( 'tutor-pagination' );
252+
if ( isset( $this->attributes['class'] ) ) {
253+
$classes[] = $this->attributes['class'];
254+
}
255+
247256
if ( count( $pagination_links ) ) {
248257
foreach ( $pagination_links as $link ) {
249258
$link = str_replace( 'page-numbers dots', 'tutor-pagination-ellipsis', $link );
@@ -258,12 +267,13 @@ public function get(): string {
258267
}
259268

260269
return sprintf(
261-
'<nav class="tutor-pagination" role="navigation" aria-label="Pagination Navigation">
270+
'<nav class="%s" role="navigation" aria-label="Pagination Navigation">
262271
%s
263272
<ul class="tutor-pagination-list">
264273
%s
265274
</ul>
266275
</nav>',
276+
esc_attr( implode( ' ', $classes ) ),
267277
$pagination_info,
268278
$links
269279
);

ecommerce/OrderController.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,14 @@ public function prepare_bulk_actions(): array {
715715
/**
716716
* Available tabs that will visible on the right side of page navbar
717717
*
718-
* @return array
719-
*
720718
* @since 3.0.0
719+
* @since 4.0.0 param $context added.
720+
*
721+
* @param string $context context.
722+
*
723+
* @return array
721724
*/
722-
public function tabs_key_value(): array {
725+
public function tabs_key_value( $context = '' ): array {
723726
$url = apply_filters( 'tutor_data_tab_base_url', get_pagenum_link() );
724727

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

740+
if ( 'dashboard' === $context ) {
741+
$start_date = Input::get( 'start_date', '' );
742+
$end_date = Input::get( 'end_date', '' );
743+
if ( ! empty( $start_date ) && ! empty( $end_date ) ) {
744+
$where['date(o.created_at_gmt)'] = array( 'BETWEEN', array( tutor_get_formated_date( '', $start_date ), tutor_get_formated_date( '', $end_date ) ) );
745+
}
746+
}
747+
737748
if ( ! empty( $payment_status ) ) {
738749
$where['o.payment_status'] = $payment_status;
739750
}

helpers/ComponentHelper.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Component Helper.
4+
*
5+
* @package Tutor\Helper
6+
* @author Themeum <support@themeum.com>
7+
* @link https://themeum.com
8+
* @since 4.0.0
9+
*/
10+
11+
namespace Tutor\Helpers;
12+
13+
use Tutor\Components\Badge;
14+
15+
/**
16+
* Class ComponentHelper
17+
*
18+
* @since 4.0.0
19+
*/
20+
class ComponentHelper {
21+
22+
/**
23+
* Order status badge
24+
*
25+
* @since 4.0.0
26+
*
27+
* @param string $status order status. It can be tutor or other monetization order status.
28+
*
29+
* @return void
30+
*/
31+
public static function order_status_badge( $status ) : void {
32+
$badge_class = 'secondary';
33+
switch ( $status ) {
34+
case 'processing':
35+
case 'pending':
36+
case 'on-hold':
37+
$badge_class = 'pending';
38+
break;
39+
case 'refunded':
40+
case 'cancelled':
41+
$badge_class = 'cancelled';
42+
break;
43+
case 'incomplete':
44+
$badge_class = 'secondary';
45+
break;
46+
case 'completed':
47+
$badge_class = 'completed';
48+
break;
49+
}
50+
51+
$label = tutor_utils()->translate_dynamic_text( $status );
52+
53+
Badge::make()->attr( 'class', 'tutor-badge-' . $badge_class )->circle()->label( $label )->render();
54+
55+
}
56+
}

0 commit comments

Comments
 (0)