Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix: Purchase history for membership based subscription plan is not showing correct info" #1531

Closed
wants to merge 1 commit into from
Closed
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: 1 addition & 6 deletions models/OrderModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,11 @@
'table' => "{$wpdb->prefix}posts AS p",
'on' => 'p.ID = oi.item_id',
),
array(
'type' => 'LEFT',
'table' => "{$wpdb->prefix}tutor_subscription_plans AS sp",
'on' => 'sp.id = oi.item_id',
),
);

$where = array( 'order_id' => $order_id );

$select_columns = array( 'oi.item_id AS id', 'oi.regular_price', 'oi.sale_price', 'oi.discount_price', 'oi.coupon_code', 'p.post_title AS title', 'p.post_type AS type', 'sp.plan_name AS plan_name', 'sp.plan_type as plan_type' );
$select_columns = array( 'oi.item_id AS id', 'oi.regular_price', 'oi.sale_price', 'oi.discount_price', 'oi.coupon_code', 'p.post_title AS title', 'p.post_type AS type' );

$courses_data = QueryHelper::get_joined_data( $primary_table, $joining_tables, $select_columns, $where, array(), 'id', 0, 0 );
$courses = $courses_data['results'];
Expand Down Expand Up @@ -877,10 +872,10 @@
"SELECT
SQL_CALC_FOUND_ROWS
o.*
FROM $this->table_name AS o

Check failure on line 875 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found interpolated variable $this at FROM $this->table_name AS o

WHERE o.user_id = %d
{$time_period_clause}

Check failure on line 877 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found interpolated variable $time_period_clause at {$time_period_clause}

{$date_range_clause}

Check failure on line 878 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found interpolated variable $date_range_clause at {$date_range_clause}

ORDER BY o.id DESC
LIMIT %d OFFSET %d
",
Expand All @@ -889,7 +884,7 @@
$offset
);

$results = $wpdb->get_results( $query );

Check failure on line 887 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found $query

if ( $wpdb->last_error ) {
throw new \Exception( $wpdb->last_error );
Expand Down Expand Up @@ -977,9 +972,9 @@
) AS total,
o.created_at_gmt AS date_format
FROM
{$this->table_name} o

Check failure on line 975 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found interpolated variable $this at {$this->table_name} o

JOIN
{$item_table} i ON o.id = i.order_id

Check failure on line 977 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found interpolated variable $item_table at {$item_table} i ON o.id = i.order_id

JOIN
{$wpdb->posts} c
ON c.ID = i.item_id
Expand All @@ -987,10 +982,10 @@
WHERE
1 = 1
AND i.item_id = %d
{$user_clause}

Check failure on line 985 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found interpolated variable $user_clause at {$user_clause}

{$period_clause}

Check failure on line 986 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found interpolated variable $period_clause at {$period_clause}

{$date_range_clause}

Check failure on line 987 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found interpolated variable $date_range_clause at {$date_range_clause}

{$group_clause}

Check failure on line 988 in models/OrderModel.php

View workflow job for this annotation

GitHub Actions / WPCS

Use placeholders and $wpdb->prepare(); found interpolated variable $group_clause at {$group_clause}

",
tutor()->course_post_type,
$course_id
Expand Down
16 changes: 5 additions & 11 deletions templates/dashboard/purchase_history.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Tutor\Helpers\DateTimeHelper;
use TUTOR\Input;
use Tutor\Models\OrderModel;
use TutorPro\Subscription\Models\PlanModel;

// Global variables.
$user_id = get_current_user_id();
Expand Down Expand Up @@ -104,7 +103,7 @@
<?php esc_html_e( 'Order ID', 'tutor' ); ?>
</th>
<th width="30%">
<?php esc_html_e( 'Name', 'tutor' ); ?>
<?php esc_html_e( 'Course Name', 'tutor' ); ?>
</th>
<th>
<?php esc_html_e( 'Date', 'tutor' ); ?>
Expand Down Expand Up @@ -139,20 +138,15 @@
<td>
<div class="tutor-fs-7">
<?php
$items = ( new OrderModel() )->get_order_items_by_id( $order->id );
$purchase_history_title = '';
$items = ( new OrderModel() )->get_order_items_by_id( $order->id );
foreach ( $items as $item ) {
$course_id = $item->id;
if ( OrderModel::TYPE_SINGLE_ORDER !== $order->order_type ) {
$course_id = apply_filters( 'tutor_subscription_course_by_plan', $item->id, $order );
$is_course_plan = $item->plan_type && ! in_array( $item->plan_type, PlanModel::get_membership_plan_types(), true );
$purchase_history_title = $is_course_plan ? get_the_title( $course_id ) : $item->plan_name;
} else {
$purchase_history_title = get_the_title( $course_id );
if ( OrderModel::TYPE_SUBSCRIPTION ) {
$course_id = apply_filters( 'tutor_subscription_course_by_plan', $item->id, $order );
}
?>
<li>
<?php echo esc_html( $purchase_history_title ); ?>
<?php echo esc_html( get_the_title( $course_id ) ); ?>
</li>
<?php
}
Expand Down
Loading