PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.20
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.20
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / app / Services / Renderer / Receipt / ReceiptRenderer.php

ReceiptRenderer.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.20, at app/Services/Renderer/Receipt/ReceiptRenderer.php

783 lines 32.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Services\Renderer\Receipt;
4
5 use FluentCart\App\Helpers\Helper;
6 use FluentCart\App\Models\OrderMeta;
7 use FluentCart\Framework\Support\Arr;
8
9 use FluentCart\Api\StoreSettings;
10 use FluentCart\App\Helpers\AddressHelper;
11 use FluentCart\App\Modules\Tax\TaxModule;
12 use FluentCart\App\Services\DateTime\DateTime;
13
14 class ReceiptRenderer
15 {
16 protected $config = null;
17
18 protected $is_first_time = false;
19
20 protected $order_operation = null;
21
22 protected $settings = null;
23
24 protected $vat_tax_id = null;
25
26 protected $orderTz;
27
28 public function __construct($config = [])
29 {
30 $this->config = $config;
31
32 $this->is_first_time = Arr::get($this->config, 'is_first_time', false);
33 $this->order_operation = Arr::get($this->config, 'order_operation', false);
34
35 $this->settings = new StoreSettings();
36
37 $this->orderTz = Arr::get($this->config, 'user_tz', 'UTC');
38 }
39
40 public function wrapperStart()
41 {
42 ?>
43 <div
44 class="fct-receipt-page"
45 style="background-color: #fff;max-width: 620px;margin-left: auto;margin-right: auto;border: 1px solid #e7eaee;padding: 10px;border-radius: 8px;">
46 <div
47 class="fct-receipt-page-inner"
48 style=" border-radius: 5px;" id="receipt">
49 <div class="fct-email-template-content email-template-content"
50 style="font-family: Arial, Helvetica, sans-serif; margin: 0 auto; padding: 0px; width: 100%;">
51 <div class="fct-email-template-content-inner" style="font-size: 13px;line-height: 1.4;color: #333;padding: 20px;">
52
53 <?php
54 }
55
56 public function wrapperEnd()
57 {
58 ?>
59 </div>
60 </div>
61 </div>
62 </div>
63 <?php
64 }
65
66 public function render($hideWrapper = false)
67 {
68
69 $order = Arr::get($this->config, 'order', null);
70 if (!$order) {
71 return;
72 }
73
74 $vatTaxId = OrderMeta::query()->where('order_id', $order->id)->where('meta_key', 'vat_tax_id')->first();
75 $this->vat_tax_id = $vatTaxId ? $vatTaxId->meta_value : '';
76
77 $this->settings = new StoreSettings();
78 $profilePage = $this->settings->getCustomerProfilePage();
79 $orderTaxRates = $order->orderTaxRates->first();
80
81 ?>
82
83 <style>
84 html {
85 background-color: rgb(248, 249, 250);
86 font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
87 }
88
89 body {
90 background-color: rgb(248, 249, 250);
91 padding-top: 40px;
92 padding-bottom: 40px;
93 font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
94 }
95
96 p {
97 font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
98 font-size: 14px;
99 margin: 0px;
100 margin-bottom: 8px;
101 line-height: 24px;
102 }
103
104 .email_footer p {
105 font-size: 12px;
106 color: rgb(127, 140, 141);
107 margin: 0px;
108 line-height: 24px;
109 margin-bottom: 8px;
110 }
111
112 hr {
113 border-color: rgb(229, 231, 235);
114 margin-bottom: 20px;
115 width: 100%;
116 border: none;
117 border-top: 1px solid #eaeaea;
118 }
119
120 .space_bottom_30 {
121 display: block;
122 width: 100%;
123 margin-bottom: 30px;
124 }
125
126 .fct-transaction-table tr:last-child td {
127 border-bottom: none !important;
128 padding-bottom: 0 !important;
129 }
130 </style>
131
132 <?php if (!$hideWrapper) {
133 $this->wrapperStart();
134 } ?>
135 <?php $this->renderHeader(); ?>
136
137 <?php $this->renderAddresses(); ?>
138
139 <?php $this->renderOrderItems(); ?>
140
141 <!-- tax note -->
142 <?php $this->renderTaxNote(); ?>
143
144 <?php $this->renderPaymentHistory(); ?>
145 <?php if (!$hideWrapper) {
146 $this->wrapperEnd();
147 } ?>
148
149
150 <?php if ($this->is_first_time) {
151 do_action('fluent_cart/order/receipt_viewed', [
152 'order' => $order,
153 'order_operation' => $this->order_operation
154 ]);
155 } ?>
156 <?php
157 }
158
159 public function renderHeader()
160 {
161 $order = Arr::get($this->config, 'order', null);
162 ?>
163 <table
164 class="fct-receipt-header"
165 role="presentation"
166 style="width: 100%;border-collapse: collapse;margin-bottom: 10px;border: none;">
167 <tbody style="width:100%">
168 <tr style="width:100%">
169 <td style="width:60%;border: none;">
170 <?php $this->renderHeaderLogo(); ?>
171
172 <!-- show tax content -->
173 <?php $this->renderStoreTaxInformation(); ?>
174 </td>
175 <td
176 class="fct-receipt-header-date"
177 style="vertical-align: middle; width: 15%; text-align: right; border: none;padding-right: 10px;">
178 <?php $this->renderHeaderOrderDate(); ?>
179 </td>
180 <td
181 class="fct-receipt-header-invoice-no"
182 style="width:15%;text-align:right;border:none;vertical-align:baseline;">
183 <?php $this->renderHeaderInvoiceNo(); ?>
184 </td>
185 </tr>
186 </tbody>
187 </table>
188 <?php
189 }
190
191 public function renderHeaderLogo()
192 {
193 ?>
194 <h1 style="font-size:24px;font-weight:700;color:rgb(17,24,39);margin:0px">
195 <?php
196 $imageLink = $this->settings->get('store_logo.url');
197 $storeName = $this->settings->get('store_name');
198 if (empty($imageLink)) {
199 echo esc_html($storeName);
200 } else {
201 echo "<img src=".esc_url($imageLink)." alt=".esc_attr($storeName)." style='max-height: 40px;'>";
202 }
203 ?>
204 </h1>
205 <?php
206 }
207
208 public function renderStoreTaxInformation()
209 {
210 $order = Arr::get($this->config, 'order', null);
211 $orderTaxRates = $order->orderTaxRates->first();
212 $storeVatNumber = Arr::get($orderTaxRates->meta ?? [], 'store_vat_number', '');
213 $taxcountry = Arr::get($orderTaxRates->meta ?? [], 'tax_country', '');
214 if (!empty($storeVatNumber)): ?>
215 <span class="fct_invoice_tax_content" style="font-weight: 500; font-size: 14px;">
216 <?php echo esc_html(TaxModule::getCountryTaxTitle($taxcountry)); ?>:
217 <?php
218 if ($storeVatNumber !== '') {
219 echo esc_html($storeVatNumber);
220 }
221 ?>
222 </span>
223 <?php endif;
224 }
225
226 public function renderHeaderOrderDate()
227 {
228 $order = Arr::get($this->config, 'order', null);
229 ?>
230 <p style="white-space: nowrap; color: #94a3b8; text-align: right; margin: 0;font-size:12px;print-color-adjust: exact;">
231 <?php echo esc_html__('Order At', 'fluent-cart'); ?>
232 </p>
233 <p style="white-space: nowrap; font-weight: bold; color: #000; text-align: right; margin: 0;font-size:14px;">
234 <?php
235 $date = wp_date(
236 get_option('date_format'),
237 DateTime::anyTimeToGmt($order->created_at)->getTimestamp(),
238 new \DateTimeZone($this->orderTz)
239 );
240 echo esc_html(Helper::translateNumber($date));
241 ?>
242 </p>
243 <?php
244 }
245
246 public function renderHeaderInvoiceNo()
247 {
248 $order = Arr::get($this->config, 'order', null);
249 ?>
250 <p style="white-space: nowrap; color: #94a3b8; text-align: right; margin: 0;font-size:12px;print-color-adjust: exact;">
251 <?php echo esc_html__('Invoice number #', 'fluent-cart'); ?>
252 </p>
253 <p id="fct-order-invoice-no"
254 style="white-space: nowrap; font-weight: bold; color: #000; text-align: right; margin: 0;font-size:14px;">
255 <?php echo esc_html($order->invoice_no); ?>
256 </p>
257 <?php
258 }
259
260 public function renderAddresses()
261 {
262 $order = Arr::get($this->config, 'order', null);
263 ?>
264
265 <?php if ($order->fulfillment_type === 'physical') : ?>
266 <div
267 class="fct-receipt-page-store-address"
268 style="background: #f8f9fa;padding: 15px;margin-bottom: 20px;print-color-adjust: exact;">
269 <?php $this->renderStoreAddress(); ?>
270 </div>
271 <?php endif; ?>
272 <div
273 class="fct-receipt-page-order-items-addresses"
274 style="display: grid;grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));gap: 20px;">
275 <?php if ($order->fulfillment_type === 'digital') : ?>
276 <div
277 class="fct-receipt-page-store-address"
278 style="border-radius: 5px;print-color-adjust: exact;">
279 <?php $this->renderStoreAddress(true); ?>
280 </div>
281 <?php endif; ?>
282 <?php $this->renderBillToAddress(); ?>
283 <?php if ($order->fulfillment_type === 'physical') : ?>
284 <?php $this->renderShipToAddress(); ?>
285 <?php endif; ?>
286 </div>
287 <?php
288 }
289
290 public function renderStoreAddress($title_border = false)
291 {
292 $order = Arr::get($this->config, 'order', null);
293 ?>
294 <?php if ($title_border) : ?>
295 <h5
296 class="fct-receipt-page-store-address-name"
297 style="font-weight: bold;font-size: 14px;margin: 0 0 10px 0;color: #495057;border-bottom: 1px solid #dee2e6;padding-bottom: 5px;">
298 <?php echo esc_html($this->settings->get('store_name')); ?>
299 </h5>
300 <?php else: ?>
301 <div
302 class="fct-receipt-page-store-address-name"
303 style="font-size: 18px;font-weight: bold;margin-bottom: 8px;">
304 <?php echo esc_html($this->settings->get('store_name')); ?>
305 </div>
306 <?php endif; ?>
307 <div
308 class="fct-receipt-page-store-address-address"
309 style="margin-bottom: 3px;">
310 <?php echo esc_html($this->settings->getFormattedFullAddress()); ?>
311 </div>
312 <?php
313 }
314
315 public function renderBillToAddress()
316 {
317 $order = Arr::get($this->config, 'order', null);
318 $orderTaxRates = $order->orderTaxRates->first();
319 ?>
320 <div
321 class="fct-receipt-page-order-items-addresses-bill-to"
322 style="border-radius: 5px;print-color-adjust: exact;">
323 <h5
324 class="fct-receipt-page-order-items-addresses-bill-to-title"
325 style="font-weight: bold;font-size: 14px;margin: 0 0 10px 0;color: #495057;border-bottom: 1px solid #dee2e6;padding-bottom: 5px;">
326 <?php echo esc_html__('Bill To', 'fluent-cart'); ?>
327 </h5>
328 <?php if (!empty($order->billing_address)) : ?>
329
330 <div
331 class="fct-receipt-page-order-items-addresses-bill-to-address"
332 style="margin-bottom: 3px;">
333 <?php echo esc_html($order->billing_address->getAddressAsText()); ?>
334 </div>
335 <?php if (!empty($this->vat_tax_id)) : ?>
336 <div
337 class="fct-receipt-page-order-items-addresses-bill-to-vat-number"
338 style="margin-bottom: 3px;">
339 <?php echo esc_html__('VAT/Tax ID:', 'fluent-cart') . ' ' . esc_html($this->vat_tax_id); ?>
340 </div>
341 <?php endif; ?>
342 <div
343 class="fct-receipt-page-order-items-addresses-bill-to-email"
344 style="margin-top: 10px;">
345 <?php echo esc_html($order->customer->email); ?>
346
347 </div>
348 <?php
349 $phoneNumber = Arr::get($order->billing_address->meta ?? [], 'other_data.phone', '');
350 if ($phoneNumber !== ''):
351 ?>
352 <div
353 class="fct-receipt-page-order-items-addresses-bill-to-phone"
354 style="margin-top: 3px;">
355 <?php echo esc_html($phoneNumber); ?>
356 </div>
357 <?php endif; ?>
358 <div class="fct-receipt-page-order-items-addresses-bill-to-company-name">
359 <?php
360 $companyName = Arr::get($order->billing_address->meta ?? [], 'other_data.company_name', '');
361 if ($companyName == '') {
362 $companyName = Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.name', '');
363 }
364 echo esc_html($companyName);
365 ?>
366 </div>
367 <div
368 class="fct-receipt-page-order-items-addresses-bill-to-vat-number"
369 style="margin-top: 5px;">
370 <?php
371 $vatNumber = Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.vat_number', '');
372
373 if ($vatNumber !== '') {
374 echo esc_html__('EU VAT', 'fluent-cart') . ': ' . esc_html($vatNumber);
375 }
376 ?>
377 </div>
378
379 <?php else: ?>
380 <div
381 class="fct-receipt-page-order-items-addresses-bill-to-name"
382 style="margin-top: 10px;">
383 <?php echo esc_html($order->customer->full_name); ?>
384 </div>
385 <?php if (!empty($vat_tax_id)) : ?>
386 <div
387 class="fct-receipt-page-order-items-addresses-bill-to-vat-number"
388 style="margin-bottom: 3px;">
389 <?php echo esc_html__('VAT/Tax ID:', 'fluent-cart') . ' ' . esc_html($vat_tax_id); ?>
390 </div>
391 <?php endif; ?>
392 <div
393 class="fct-receipt-page-order-items-addresses-bill-to-email"
394 style="margin-top: 3px;">
395 <?php echo esc_html($order->customer->email); ?>
396 </div>
397 <?php endif; ?>
398 </div>
399 <?php
400 }
401
402 public function renderShipToAddress()
403 {
404 $order = Arr::get($this->config, 'order', null);
405 ?>
406 <div
407 class="fct-receipt-page-order-items-addresses-ship-to"
408 style="border-radius: 5px;print-color-adjust: exact;">
409 <h5
410 class="fct-receipt-page-order-items-addresses-ship-to-title"
411 style="font-weight: bold;font-size: 14px;margin: 0 0 10px 0;color: #495057;border-bottom: 1px solid #dee2e6;padding-bottom: 5px;">
412 <?php echo esc_html__('Ship To', 'fluent-cart'); ?>
413 </h5>
414 <?php if (!empty($order->shipping_address)) : ?>
415 <div
416 class="fct-receipt-page-order-items-addresses-ship-to-address"
417 style="margin-bottom: 3px;">
418 <?php echo esc_html($order->shipping_address->getAddressAsText()); ?>
419 </div>
420 <?php
421 $phone = Arr::get($order->shipping_address->meta ?? [], 'other_data.phone', '');
422 if ($phone !== ''):
423 ?>
424 <div
425 class="fct-receipt-page-order-items-addresses-ship-to-phone"
426 style="margin-top: 3px;">
427 <?php echo esc_html($phone); ?>
428 </div>
429 <?php endif; ?>
430 <?php else: ?>
431 <div
432 class="fct-receipt-page-order-items-addresses-ship-to-name"
433 style="margin-top: 10px;">
434 <?php echo esc_html($order->customer->full_name); ?>
435 </div>
436 <div
437 class="fct-receipt-page-order-items-addresses-ship-to-email"
438 style="margin-top: 3px;">
439 <?php echo esc_html($order->customer->email); ?>
440 </div>
441 <?php endif; ?>
442 </div>
443 <?php
444 }
445
446 public function renderOrderItems()
447 {
448 $order = Arr::get($this->config, 'order', null);
449 if ($order->order_items) : ?>
450 <?php $this->renderOrderItemsTable(); ?>
451
452 <?php $this->renderOrderItemsFooter(); ?>
453 <?php endif;
454 }
455
456 public function renderOrderItemsTable()
457 {
458 $order = Arr::get($this->config, 'order', null);
459 if ($order->order_items) : ?>
460 <table
461 class="fct-receipt-page-order-items-table"
462 style="margin-top: 20px;margin-bottom: 10px;width: 100%;text-align: left;border-spacing: 0;border-collapse: collapse;border: none;">
463 <thead>
464 <tr>
465 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;print-color-adjust: exact;border: none;">
466 <?php echo esc_html__('Description', 'fluent-cart'); ?>
467 </th>
468 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;width: 80px;text-align: right;print-color-adjust: exact;border: none;">
469 <?php echo esc_html__('Qty', 'fluent-cart'); ?>
470 </th>
471 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;width: 80px;text-align: right;print-color-adjust: exact;border: none;">
472 <?php echo esc_html__('Unit price', 'fluent-cart'); ?>
473 </th>
474 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;width: 80px;text-align: right;print-color-adjust: exact;border: none;">
475 <?php echo esc_html__('Amount', 'fluent-cart'); ?>
476 </th>
477 </tr>
478 </thead>
479 <tbody>
480 <?php
481 $orderItems = $order->order_items->toArray();
482 $transaction = $order->getLatestTransaction();
483
484 foreach ($orderItems as $item) :
485 ?>
486 <tr>
487 <td style="font-size:15px;padding: 12px 8px;border: none;border-bottom: 1px solid #dee2e6;print-color-adjust: exact;">
488 <?php echo esc_html($item['post_title']); ?>
489 <br>
490 <?php if (!empty($item['title'])) : ?>
491 <small style="font-size: 13px;color: #758195;">- <?php echo esc_html($item['title']); ?></small>
492 <br>
493 <?php endif; ?>
494 <?php if (!empty($item['payment_info'])) : ?>
495 <small style="font-size: 13px;color: #758195;"><?php echo esc_html($item['payment_info']); ?></small>
496 <?php endif; ?>
497 </td>
498 <td style="padding: 12px 8px;border: none;border-bottom: 1px solid #dee2e6;text-align: right;">
499 <?php echo esc_html(Helper::translateNumber($item['quantity'])); ?>
500 </td>
501 <td style="padding: 12px 8px;border: none;border-bottom: 1px solid #dee2e6;text-align: right">
502 <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice($item['unit_price'], null, false, true, true)); ?>
503 </td>
504 <td style="padding: 12px 8px;border: none;border-bottom: 1px solid #dee2e6;text-align: right">
505 <?php echo esc_html($item['formatted_total']); ?>
506 </td>
507 </tr>
508 <?php endforeach; ?>
509 </tbody>
510 </table>
511 <?php endif;
512 }
513
514 public function renderOrderItemsFooter()
515 {
516 $order = Arr::get($this->config, 'order', null);
517 ?>
518 <div
519 class="fct-receipt-page-order-items-footer"
520 style="margin-top: 20px;">
521 <table
522 class="fct-receipt-page-order-items-footer-table"
523 style="max-width: 250px;width: 100%;margin-left: auto;border-collapse: collapse;background: #f8f9fa;print-color-adjust: exact;border: none;">
524 <tbody>
525 <?php $this->renderSubtotal(); ?>
526 <?php $this->renderDiscount(); ?>
527 <?php $this->renderShipping(); ?>
528 <?php $this->renderFees(); ?>
529 <?php $this->renderTaxTotal(); ?>
530 <?php $this->renderShippingTax(); ?>
531 <?php $this->renderRefund(); ?>
532 <?php $this->renderTotal(); ?>
533 <?php $this->renderAmountPaid(); ?>
534 </tbody>
535 </table>
536 </div>
537 <?php
538 }
539
540 public function renderSubtotal()
541 {
542 $order = Arr::get($this->config, 'order', null);
543 if ($order->subtotal != ($order->total_amount - $order->total_refund) || $order->tax_total > 0): ?>
544 <tr>
545 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
546 <?php echo esc_html__('Subtotal', 'fluent-cart'); ?>
547 </td>
548 <td style="font-weight:700;padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
549 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->subtotal));
550 ?>
551 </td>
552 </tr>
553 <?php endif;
554 }
555
556 public function renderDiscount()
557 {
558 $order = Arr::get($this->config, 'order', null);
559 if ($order->manual_discount_total + $order->coupon_discount_total > 0): ?>
560 <tr>
561 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
562 <?php echo esc_html__('Discount', 'fluent-cart'); ?>
563 </td>
564 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
565 - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->manual_discount_total + $order->coupon_discount_total)); ?>
566 </td>
567 </tr>
568 <?php endif;
569 }
570
571 public function renderShipping()
572 {
573 $order = Arr::get($this->config, 'order', null);
574 if ($order->shipping_total > 0): ?>
575 <tr>
576 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
577 <?php echo esc_html__('Shipping', 'fluent-cart'); ?>
578 </td>
579 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
580 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->shipping_total)); ?>
581 </td>
582 </tr>
583 <?php endif;
584 }
585
586 public function renderFees()
587 {
588 $order = Arr::get($this->config, 'order', null);
589 if (!$order || $order->fee_total <= 0) {
590 return;
591 }
592 $feeItems = $order->feeItems()->get();
593 foreach ($feeItems as $feeItem): ?>
594 <tr>
595 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
596 <?php echo esc_html($feeItem->title); ?>
597 </td>
598 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
599 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($feeItem->subtotal)); ?>
600 </td>
601 </tr>
602 <?php endforeach;
603 }
604
605 public function renderTaxTotal()
606 {
607 $order = Arr::get($this->config, 'order', null);
608 if ($order->tax_total > 0): ?>
609 <tr>
610 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
611 <?php echo esc_html__('Tax', 'fluent-cart');
612 echo esc_html($order->tax_behavior == 2 ? __('(Included)', 'fluent-cart') : __('(Excluded)', 'fluent-cart'));
613 ?>
614 </td>
615 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
616 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->tax_total)); ?>
617 </td>
618 </tr>
619 <?php endif;
620 }
621
622 public function renderShippingTax()
623 {
624 $order = Arr::get($this->config, 'order', null);
625 if ($order->shipping_tax > 0): ?>
626 <tr>
627 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
628 <?php echo esc_html__('Shipping Tax', 'fluent-cart');
629 echo esc_html($order->tax_behavior == 2 ? __('(Included)', 'fluent-cart') : __('(Excluded)', 'fluent-cart'));
630 ?>
631 </td>
632 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
633 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->shipping_tax)); ?>
634 </td>
635 </tr>
636 <?php endif;
637 }
638
639 public function renderRefund()
640 {
641 $order = Arr::get($this->config, 'order', null);
642 if ($order->total_refund > 0): ?>
643 <tr style="font-weight: bold;font-size: 14px;">
644 <td style="font-weight:500;padding: 8px 20px 8px 0;text-align: right;border:none;">
645 <?php echo esc_html__('Refund', 'fluent-cart'); ?>
646 </td>
647 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border:none;">
648 - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->total_refund)); ?>
649 </td>
650 </tr>
651 <?php endif;
652 }
653
654 public function renderTotal()
655 {
656 $order = Arr::get($this->config, 'order', null);
657 ?>
658 <tr style="font-weight: bold;font-size: 14px;">
659 <td style="font-weight:500;padding: 8px 20px 8px 0;text-align: right;border:none;">
660 <?php echo esc_html__('Total', 'fluent-cart'); ?>
661 </td>
662 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border:none;">
663 <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice(($order->total_amount - $order->total_refund), null, false, true, true)); ?>
664 </td>
665 </tr>
666 <?php
667 }
668
669 public function renderAmountPaid()
670 {
671 $order = Arr::get($this->config, 'order', null);
672 ?>
673 <tr style="font-weight: bold;font-size: 14px;">
674 <td style="font-weight:500;padding: 8px 20px 8px 0;text-align: right;border:none;">
675 <?php echo esc_html__('Amount Paid', 'fluent-cart'); ?>
676 </td>
677 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border:none;">
678 <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice(($order->total_paid - $order->total_refund), null, false, true, true)); ?>
679 </td>
680 </tr>
681 <?php
682 }
683
684 public function renderTaxNote()
685 {
686 $order = Arr::get($this->config, 'order', null);
687 $taxtotal = $order->tax_total + $order->shipping_tax;
688 if (Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.valid') && !$taxtotal): ?>
689
690 <div style="text-align: right; font-size: 14px; margin-top: 10px;">
691 <?php echo esc_html__('* Tax to be paid on reverse charge basis', 'fluent-cart'); ?>
692 </div>
693
694 <?php endif;
695 }
696
697 public function renderPaymentHistory()
698 {
699 $order = Arr::get($this->config, 'order', null);
700 $transactions = $order->transactions;
701 if (!empty($transactions)) :
702 ?>
703 <div
704 class="fct-payment-history"
705 style="margin-top: 30px;">
706 <div
707 class="fct-payment-history-heading"
708 style="font-weight: bold;font-size: 14px;color: #495057;margin: 0;padding: 0;">
709 <?php echo esc_html__('Payment history', 'fluent-cart'); ?>
710 </div>
711 <table class="fct-transaction-table"
712 style="margin-top: 10px;width: 100%;text-align: left;border-spacing: 0;border-collapse: collapse;border: none;">
713 <thead>
714 <tr>
715 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;print-color-adjust: exact;border:none;">
716 <?php echo esc_html__('Payment method', 'fluent-cart'); ?>
717 </th>
718 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold; text-align: center;print-color-adjust: exact;border:none;">
719 <?php echo esc_html__('Date', 'fluent-cart'); ?>
720 </th>
721 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold; text-align: right;print-color-adjust: exact;border:none;">
722 <?php echo esc_html__('Amount', 'fluent-cart'); ?>
723 </th>
724 </tr>
725 </thead>
726 <tbody>
727 <?php foreach ($transactions as $transaction) :
728 if ($transaction->transaction_type === 'refund') {
729 continue;
730 }
731 ?>
732 <tr>
733 <td style="padding: 10px;border:none;border-bottom: 1px solid #dee2e6;">
734 <?php echo esc_html($transaction->getPaymentMethodText()); ?>
735 </td>
736 <td style="padding: 10px;border:none;border-bottom: 1px solid #dee2e6;text-align: center;">
737 <?php
738 $date = wp_date(
739 get_option('date_format'),
740 DateTime::anyTimeToGmt($transaction->created_at)->getTimestamp(),
741 new \DateTimeZone($this->orderTz)
742 );
743 echo esc_html(Helper::translateNumber($date));
744 ?>
745 </td>
746 <td style="padding: 10px;border:none;border-bottom: 1px solid #dee2e6;text-align: right;">
747 <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice($transaction->total, null, false, true, true)); ?>
748 </td>
749 </tr>
750 <?php endforeach; ?>
751 </tbody>
752 </table>
753 </div>
754 <?php endif;
755 }
756
757 public function renderConfirmationError($errorData)
758 {
759 $failed_reason = Arr::get($errorData, 'failed_reason', '');
760 $custom_payment_url = Arr::get($errorData, 'custom_payment_url', '');
761 ?>
762 <style>
763 .fluent_cart_confirmation_failed {
764 max-width: 700px;
765 margin: 0 auto;
766 padding: 30px;
767 border-radius: 9px;
768 box-shadow: 1px 1px 5px 0px #ccc;
769 border-left: 3px solid red;
770 }
771 </style>
772 <div class="fluent_cart_confirmation_failed">
773 <h3><?php echo esc_html__('Payment Confirmation Failed!', 'fluent-cart'); ?></h3>
774 <span><?php echo esc_html__('We are sorry, your order is placed but payment confirmation has failed.', 'fluent-cart'); ?></span>
775 <?php if ($failed_reason) : ?>
776 <p style="color:red;font-style: italic;"><?php echo esc_html__('Failure reason: ', 'fluent-cart') . esc_html($failed_reason) ?></p>
777 <?php endif; ?>
778 <span><?php echo esc_html__('Please try to complete payment again from here!', 'fluent-cart'); ?></span>
779 <a href="<?php echo esc_url($custom_payment_url ?? ''); ?>"><?php echo esc_url($custom_payment_url); ?></a>
780 </div>
781 <?php }
782 }
783