Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor-pro/templates/invoice.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
/**
3
+
* Invoice template
4
+
*
5
+
* @package TutorPro\Templates
6
+
* @author Themeum <support@themeum.com>
7
+
* @link https://themeum.com
8
+
* @since 3.0.0
9
+
*/
10
+
11
+
use Tutor\Ecommerce\OrderController;
12
+
use Tutor\Helpers\DateTimeHelper;
13
+
use TUTOR\Input;
14
+
use Tutor\Models\OrderModel;
15
+
use TutorPro\Ecommerce\Invoice;
16
+
use Tutor\Ecommerce\Ecommerce;
17
+
use TUTOR\User;
18
+
use TutorPro\Subscription\Models\SubscriptionModel;
19
+
20
+
if ( ! defined( 'ABSPATH' ) ) {
21
+
exit;
22
+
}
23
+
24
+
$order_model = new OrderModel();
25
+
$user_id = get_current_user_id();
26
+
$order_id = Input::get( 'invoice', 0, Input::TYPE_INT );
27
+
$params = array( 'id' => $order_id );
28
+
29
+
if ( ! User::is_admin() ) {
30
+
$params['user_id'] = $user_id;
31
+
}
32
+
33
+
$order_record = $order_model->get_row( $params );
34
+
if ( ! Invoice::should_show_invoice( $order_record ) ) {
35
+
tutor_utils()->tutor_empty_state( __( 'No data found!', 'tutor-pro' ) );
36
+
return;
37
+
}
38
+
39
+
$order_data = $order_model->get_order_by_id( $order_id );
40
+
41
+
$back_link = tutor_utils()->get_tutor_dashboard_page_permalink( 'purchase_history' );
42
+
if ( is_admin() ) {
43
+
$back_link = OrderController::get_order_page_url();
44
+
};
45
+
46
+
$subscription_id = Input::get( 'subscription' );
47
+
if ( $subscription_id ) {
48
+
$back_link = SubscriptionModel::get_subscription_details_url( $subscription_id, is_admin() ? 'backend' : 'frontend' );
49
+
}
50
+
51
+
$site_url = site_url();
52
+
$site_name = get_bloginfo( 'name' );
53
+
$placeholder_url = tutor()->url . 'assets/images/placeholder.svg';
54
+
55
+
$billing_info = OrderModel::get_order_billing_address( $order_id, $order_data->user_id );
56
+
57
+
$billing_full_name = $billing_info->full_name;
58
+
$billing_email = $billing_info->email;
59
+
$billing_phone = $billing_info->phone;
60
+
$billing_zip_code = $billing_info->zip_code;
61
+
$billing_address = $billing_info->address;
62
+
$billing_city = $billing_info->city;
63
+
64
+
$from_address = tutor_utils()->get_option( 'invoice_from_address', '' );
65
+
$subscription_order = OrderModel::TYPE_SUBSCRIPTION === $order_data->order_type;
66
+
$subscription_addon_enabled = tutor_utils()->is_addon_enabled( 'subscription' );
67
+
68
+
$plan_id = null;
69
+
$plan_info = null;
70
+
$is_membership_plan = false;
71
+
if ( $subscription_order ) {
72
+
$plan_id = $order_data->items[0]->id ?? 0;
73
+
$plan_info = apply_filters( 'tutor_get_plan_info', null, $plan_id );
74
+
if ( $plan_info && isset( $plan_info->is_membership_plan ) && $plan_info->is_membership_plan ) {
75
+
$is_membership_plan = true;
76
+
}
77
+
}
78
+
79
+
?>
80
+
81
+
<div class="<?php echo esc_attr( is_admin() ? 'tutor-admin-wrap' : '' ); ?>">
82
+
<div class="<?php echo esc_attr( is_admin() ? 'tutor-wp-dashboard-header tutor-px-24 tutor-py-16 tutor-mb-24' : '' ); ?>">
83
+
<div class="tutor-d-flex tutor-justify-between <?php echo esc_attr( is_admin() ? '' : 'tutor-mb-24' ); ?>">
84
+
<a class="tutor-btn tutor-btn-ghost" href="<?php echo esc_url( $back_link ); ?>">
85
+
<span class="tutor-icon-previous tutor-mr-8" area-hidden="true"></span>
86
+
<?php esc_html_e( 'Back', 'tutor-pro' ); ?>
87
+
</a>
88
+
<button id="tutor-download-invoice" class="tutor-btn tutor-btn-secondary" data-order-id="<?php echo esc_attr( $order_data->id ); ?>">
89
+
<i class="tutor-icon-download tutor-mr-4"></i>
90
+
<?php esc_html_e( 'Download Invoice', 'tutor-pro' ); ?>
91
+
</button>
92
+
</div>
93
+
</div>
94
+
95
+
<div class="tutor-invoice-wrapper">
96
+
<div id="tutor-invoice-content" class="tutor-invoice">
97
+
<div class="invoice-header">
98
+
<div>
99
+
<h1><?php esc_html_e( 'INVOICE', 'tutor-pro' ); ?> <span class="status"><?php echo esc_html( ucwords( tutor_utils()->translate_dynamic_text( $order_data->payment_status ) ) ); ?></span></h1>
100
+
<p class="invoice-number">#<?php echo esc_html( $order_id ); ?></p>
101
+
</div>
102
+
<?php
103
+
if ( has_custom_logo() ) :
104
+
$custom_logo_id = get_theme_mod( 'custom_logo' );
105
+
$logo_url = wp_get_attachment_image_url( $custom_logo_id, 'full' );
106
+
?>
107
+
<div class="site-logo">
108
+
<img src="<?php echo esc_url( $logo_url ); ?>" alt="<?php echo esc_attr( $site_name ); ?>">
109
+
</div>
110
+
<?php endif; ?>
111
+
</div>
112
+
113
+
<div class="invoice-info tutor-fs-8 tutor-border-top tutor-border-bottom">
114
+
<div class="tutor-p-16 tutor-pl-0 tutor-fw-bold tutor-border-right">
115
+
<div class="tutor-mb-16">
116
+
<div class="tutor-mb-4"><?php esc_html_e( 'Invoice date', 'tutor-pro' ); ?></div>
117
+
<div class="tutor-color-subdued"><?php echo esc_html( DateTimeHelper::get_gmt_to_user_timezone_date( $order_data->created_at_gmt, 'd M, Y' ) ); ?></div>
118
+
</div>
119
+
<div class="tutor-mb-16">
120
+
<div class="tutor-mb-4"><?php esc_html_e( 'Payment method', 'tutor-pro' ); ?></div>
121
+
<div class="tutor-color-subdued"><?php echo esc_html( Ecommerce::get_payment_method_label( $order_data->payment_method ) ); ?></div>
122
+
</div>
123
+
</div>
124
+
<div class="tutor-p-16 tutor-border-right">
125
+
<div class="tutor-mb-12">
126
+
<div class="tutor-fw-bold tutor-mb-4"><?php esc_html_e( 'Billed to', 'tutor-pro' ); ?></div>
127
+
<div class="tutor-fw-bold tutor-color-subdued"><?php echo esc_html( $billing_full_name ); ?></div>
128
+
<div class="tutor-color-subdued">
129
+
<?php echo esc_html( $billing_email ); ?><br>
130
+
<?php echo esc_html( $billing_phone ); ?><br>
131
+
<?php echo esc_html( $billing_address ); ?><br>
132
+
<?php echo esc_html( $billing_city ) . '-' . esc_html( $billing_zip_code ); ?>
133
+
</div>
134
+
</div>
135
+
</div>
136
+
<div class="tutor-p-16">
137
+
<div class="tutor-mb-12">
138
+
<div class="tutor-fw-bold tutor-mb-4"><?php esc_html_e( 'From', 'tutor-pro' ); ?></div>
139
+
<div class="tutor-fw-bold tutor-color-subdued"><?php echo esc_html( $site_name ); ?></div>
140
+
<div class="tutor-color-subdued">
141
+
<?php
142
+
echo wp_kses(
143
+
nl2br( $from_address ),
144
+
array(
145
+
'br' => array(),
146
+
)
147
+
);
148
+
?>
149
+
</div>
150
+
</div>
151
+
</div>
152
+
</div>
153
+
154
+
<table class="invoice-table">
155
+
<thead>
156
+
<tr>
157
+
<th><?php esc_html_e( 'Item', 'tutor-pro' ); ?></th>
158
+
<?php
159
+
if ( $subscription_addon_enabled && $plan_info ) :
160
+
$label = __( 'Plan', 'tutor-pro' );
161
+
if ( $is_membership_plan ) {
162
+
$label = __( 'Access', 'tutor-pro' );
163
+
}
164
+
?>
165
+
<th><?php echo esc_html( $label ); ?></th>
166
+
<?php endif; ?>
167
+
<th class="price"><?php esc_html_e( 'Price', 'tutor-pro' ); ?></th>
168
+
</tr>
169
+
</thead>
170
+
<tbody>
171
+
<?php
172
+
foreach ( $order_data->items as $item ) :
173
+
$display_price = $order_model->get_order_item_display_price( $item );
174
+
$has_sale_price = is_numeric( $item->sale_price ) || is_numeric( $item->discount_price );
175
+
$thumbnail_url = $item->image ? $item->image : $placeholder_url;
176
+
?>
177
+
<tr>
178
+
<td>
179
+
<div class="tutor-d-flex tutor-gap-1">
180
+
<?php
181
+
if ( ! empty( $thumbnail_url ) ) :
182
+
?>
183
+
<div class="item-image">
184
+
<img src="<?php echo esc_url( $thumbnail_url ); ?>" alt="<?php echo esc_attr( $item->title ); ?>">
185
+
</div>
186
+
187
+
<?php endif; ?>
188
+
<div class="tutor-fw-bold"><?php echo esc_html( $item->title ); ?>
189
+
<?php
190
+
if ( 'course-bundle' === $item->type ) :
191
+
$term_text = $item->total_courses > 1 ? __( 'Courses', 'tutor-pro' ) : __( 'Course', 'tutor-pro' );
192
+
?>
193
+
<div class="tutor-fw-normal tutor-fs-8 tutor-color-hints">
194
+
<?php
195
+
// translators: %1$s: number of courses, %2$s: term text.
196
+
echo esc_html( sprintf( __( '%1$s %2$s', 'tutor-pro' ), $item->total_courses, $term_text ) );
197
+
?>
198
+
</div>
199
+
<?php endif; ?>
200
+
<?php do_action( 'tutor_after_order_invoice_item_name', $order_data ); ?>
201
+
</div>
202
+
</div>
203
+
</td>
204
+
205
+
<?php
206
+
if ( $subscription_addon_enabled && $plan_info ) :
207
+
$plan_name = $plan_info->plan_name;
208
+
if ( $is_membership_plan ) {
209
+
$plan_name = 'full_site' === $plan_info->plan_type
210
+
? __( 'Full Site', 'tutor-pro' )
211
+
: __( 'Category', 'tutor-pro' );
212
+
}
213
+
?>
214
+
<td><?php echo esc_html( $plan_name ); ?></td>
215
+
<?php endif; ?>
216
+
217
+
<td class="price tutor-fw-medium">
218
+
<div class="tutor-color-black tutor-mb-4"><?php tutor_print_formatted_price( $display_price ); ?></div>
219
+
<?php if ( $has_sale_price ) : ?>
220
+
<del class="tutor-color-hints"><?php tutor_print_formatted_price( $item->regular_price ); ?></del>
221
+
<?php endif; ?>
222
+
</td>
223
+
</tr>
224
+
<?php endforeach; ?>
225
+
</tbody>
226
+
</table>
227
+
228
+
<div class="invoice-summary">
229
+
<?php
230
+
if ( isset( $order_data->subscription_fees ) ) :
231
+
foreach ( $order_data->subscription_fees as $fee ) :
232
+
?>
233
+
<div>
234
+
<div class="tutor-fw-bold tutor-color-black"><?php echo esc_html( $fee['title'] ?? '' ); ?></div>
235
+
<div class="tutor-fw-medium tutor-color-subdued"><?php tutor_print_formatted_price( $fee['value'] ?? 0 ); ?></div>
236
+
</div>
237
+
<?php
238
+
endforeach;
239
+
endif;
240
+
?>
241
+
<div>
242
+
<div class="tutor-fw-bold tutor-color-black"><?php esc_html_e( 'Subtotal', 'tutor-pro' ); ?></div>
243
+
<div class="tutor-fw-medium tutor-color-subdued"><?php tutor_print_formatted_price( $order_data->subtotal_price ); ?></div>
244
+
</div>
245
+
<?php if ( $order_data->discount_amount > 0 ) : ?>
246
+
<div>
247
+
<div class="tutor-fw-bold tutor-color-black"><?php esc_html_e( 'Discount', 'tutor-pro' ); ?> <span class="tutor-fw-normal tutor-color-hints">(<?php echo esc_html( $order_data->discount_reason ); ?>)</span></div>
248
+
<div class="tutor-fw-medium tutor-color-subdued">- <?php tutor_print_formatted_price( $order_data->discount_amount ); ?></div>
249
+
</div>
250
+
<?php endif; ?>
251
+
<?php if ( $order_data->coupon_amount > 0 ) : ?>
252
+
<div>
253
+
<div class="tutor-fw-bold tutor-color-black"><?php esc_html_e( 'Coupon', 'tutor-pro' ); ?> <span class="tutor-fw-normal tutor-color-hints">(<?php echo esc_html( $order_data->coupon_code ); ?>)</span></div>
254
+
<div class="tutor-fw-medium tutor-color-subdued">- <?php tutor_print_formatted_price( $order_data->coupon_amount ); ?></div>
255
+
</div>
256
+
<?php endif; ?>
257
+
<?php if ( $order_model->has_exclusive_tax( $order_data ) ) : ?>
258
+
<div>
259
+
<div class="tutor-fw-bold tutor-color-black"><?php esc_html_e( 'Tax', 'tutor-pro' ); ?> <span class="tutor-fw-normal tutor-color-hints">(<?php echo esc_html( $order_data->tax_rate . '%' ); ?>)</span></div>
260
+
<div class="tutor-fw-medium tutor-color-subdued"><?php tutor_print_formatted_price( $order_data->tax_amount ); ?></div>
261
+
</div>
262
+
<?php endif; ?>
263
+
<div>
264
+
<div class="tutor-fw-bold tutor-color-black"><?php esc_html_e( 'Total', 'tutor-pro' ); ?>
265
+
<?php if ( $order_model->has_inclusive_tax( $order_data ) ) : ?>
266
+
<span class="tutor-fw-normal tutor-color-hints">(<?php esc_html_e( 'Incl. tax', 'tutor-pro' ); ?> <?php tutor_print_formatted_price( $order_data->tax_amount ); ?>)</span>
267
+
<?php endif; ?>
268
+
</div>
269
+
<strong class="tutor-fw-bold tutor-color-black"><?php tutor_print_formatted_price( $order_data->total_price ); ?></strong>
270
+
</div>
271
+
</div>
272
+
273
+
<div class="invoice-footer">
274
+
<div class="footer-bottom">
275
+
<div><?php echo esc_url( $site_url ); ?></div>
276
+
</div>
277
+
</div>
278
+
</div>
279
+
</div>
280
+
</div>
281
+