PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.27
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.27
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.27, at app/Services/Renderer/Receipt/ReceiptRenderer.php

794 lines 32.8 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 $orderTaxRates = $order->orderTaxRates->first();
314 $storeVatNumber = Arr::get($orderTaxRates->meta ?? [], 'store_vat_number', '');
315 $taxCountry = Arr::get($orderTaxRates->meta ?? [], 'tax_country', '');
316 if (!empty($storeVatNumber)): ?>
317 <div
318 class="fct-receipt-page-store-address-vat"
319 style="margin-top: 5px;font-weight: 500;">
320 <?php echo esc_html(TaxModule::getCountryTaxTitle($taxCountry)) . ': ' . esc_html($storeVatNumber); ?>
321 </div>
322 <?php endif;
323 }
324
325 public function renderBillToAddress()
326 {
327 $order = Arr::get($this->config, 'order', null);
328 $orderTaxRates = $order->orderTaxRates->first();
329 ?>
330 <div
331 class="fct-receipt-page-order-items-addresses-bill-to"
332 style="border-radius: 5px;print-color-adjust: exact;">
333 <h5
334 class="fct-receipt-page-order-items-addresses-bill-to-title"
335 style="font-weight: bold;font-size: 14px;margin: 0 0 10px 0;color: #495057;border-bottom: 1px solid #dee2e6;padding-bottom: 5px;">
336 <?php echo esc_html__('Bill To', 'fluent-cart'); ?>
337 </h5>
338 <?php if (!empty($order->billing_address)) : ?>
339
340 <div
341 class="fct-receipt-page-order-items-addresses-bill-to-address"
342 style="margin-bottom: 3px;">
343 <?php echo esc_html($order->billing_address->getAddressAsText()); ?>
344 </div>
345 <?php if (!empty($this->vat_tax_id)) : ?>
346 <div
347 class="fct-receipt-page-order-items-addresses-bill-to-vat-number"
348 style="margin-bottom: 3px;">
349 <?php echo esc_html__('VAT/Tax ID:', 'fluent-cart') . ' ' . esc_html($this->vat_tax_id); ?>
350 </div>
351 <?php endif; ?>
352 <div
353 class="fct-receipt-page-order-items-addresses-bill-to-email"
354 style="margin-top: 10px;">
355 <?php echo esc_html($order->customer->email); ?>
356
357 </div>
358 <?php
359 $phoneNumber = Arr::get($order->billing_address->meta ?? [], 'other_data.phone', '');
360 if ($phoneNumber !== ''):
361 ?>
362 <div
363 class="fct-receipt-page-order-items-addresses-bill-to-phone"
364 style="margin-top: 3px;">
365 <?php echo esc_html($phoneNumber); ?>
366 </div>
367 <?php endif; ?>
368 <div class="fct-receipt-page-order-items-addresses-bill-to-company-name">
369 <?php
370 $companyName = Arr::get($order->billing_address->meta ?? [], 'other_data.company_name', '');
371 if ($companyName == '') {
372 $companyName = Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.name', '');
373 }
374 echo esc_html($companyName);
375 ?>
376 </div>
377 <div
378 class="fct-receipt-page-order-items-addresses-bill-to-vat-number"
379 style="margin-top: 5px;">
380 <?php
381 $vatNumber = Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.vat_number', '');
382
383 if ($vatNumber !== '') {
384 echo esc_html__('EU VAT', 'fluent-cart') . ': ' . esc_html($vatNumber);
385 }
386 ?>
387 </div>
388
389 <?php else: ?>
390 <div
391 class="fct-receipt-page-order-items-addresses-bill-to-name"
392 style="margin-top: 10px;">
393 <?php echo esc_html($order->customer->full_name); ?>
394 </div>
395 <?php if (!empty($vat_tax_id)) : ?>
396 <div
397 class="fct-receipt-page-order-items-addresses-bill-to-vat-number"
398 style="margin-bottom: 3px;">
399 <?php echo esc_html__('VAT/Tax ID:', 'fluent-cart') . ' ' . esc_html($vat_tax_id); ?>
400 </div>
401 <?php endif; ?>
402 <div
403 class="fct-receipt-page-order-items-addresses-bill-to-email"
404 style="margin-top: 3px;">
405 <?php echo esc_html($order->customer->email); ?>
406 </div>
407 <?php endif; ?>
408 </div>
409 <?php
410 }
411
412 public function renderShipToAddress()
413 {
414 $order = Arr::get($this->config, 'order', null);
415 ?>
416 <div
417 class="fct-receipt-page-order-items-addresses-ship-to"
418 style="border-radius: 5px;print-color-adjust: exact;">
419 <h5
420 class="fct-receipt-page-order-items-addresses-ship-to-title"
421 style="font-weight: bold;font-size: 14px;margin: 0 0 10px 0;color: #495057;border-bottom: 1px solid #dee2e6;padding-bottom: 5px;">
422 <?php echo esc_html__('Ship To', 'fluent-cart'); ?>
423 </h5>
424 <?php if (!empty($order->shipping_address)) : ?>
425 <div
426 class="fct-receipt-page-order-items-addresses-ship-to-address"
427 style="margin-bottom: 3px;">
428 <?php echo esc_html($order->shipping_address->getAddressAsText()); ?>
429 </div>
430 <?php
431 $phone = Arr::get($order->shipping_address->meta ?? [], 'other_data.phone', '');
432 if ($phone !== ''):
433 ?>
434 <div
435 class="fct-receipt-page-order-items-addresses-ship-to-phone"
436 style="margin-top: 3px;">
437 <?php echo esc_html($phone); ?>
438 </div>
439 <?php endif; ?>
440 <?php else: ?>
441 <div
442 class="fct-receipt-page-order-items-addresses-ship-to-name"
443 style="margin-top: 10px;">
444 <?php echo esc_html($order->customer->full_name); ?>
445 </div>
446 <div
447 class="fct-receipt-page-order-items-addresses-ship-to-email"
448 style="margin-top: 3px;">
449 <?php echo esc_html($order->customer->email); ?>
450 </div>
451 <?php endif; ?>
452 </div>
453 <?php
454 }
455
456 public function renderOrderItems()
457 {
458 $order = Arr::get($this->config, 'order', null);
459 if ($order->order_items) : ?>
460 <?php $this->renderOrderItemsTable(); ?>
461
462 <?php $this->renderOrderItemsFooter(); ?>
463 <?php endif;
464 }
465
466 public function renderOrderItemsTable()
467 {
468 $order = Arr::get($this->config, 'order', null);
469 if ($order->order_items) : ?>
470 <table
471 class="fct-receipt-page-order-items-table"
472 style="margin-top: 20px;margin-bottom: 10px;width: 100%;text-align: left;border-spacing: 0;border-collapse: collapse;border: none;">
473 <thead>
474 <tr>
475 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;print-color-adjust: exact;border: none;">
476 <?php echo esc_html__('Description', 'fluent-cart'); ?>
477 </th>
478 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;width: 80px;text-align: right;print-color-adjust: exact;border: none;">
479 <?php echo esc_html__('Qty', 'fluent-cart'); ?>
480 </th>
481 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;width: 80px;text-align: right;print-color-adjust: exact;border: none;">
482 <?php echo esc_html__('Unit price', 'fluent-cart'); ?>
483 </th>
484 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;width: 80px;text-align: right;print-color-adjust: exact;border: none;">
485 <?php echo esc_html__('Amount', 'fluent-cart'); ?>
486 </th>
487 </tr>
488 </thead>
489 <tbody>
490 <?php
491 $orderItems = $order->order_items->toArray();
492 $transaction = $order->getLatestTransaction();
493
494 foreach ($orderItems as $item) :
495 ?>
496 <tr>
497 <td style="font-size:15px;padding: 12px 8px;border: none;border-bottom: 1px solid #dee2e6;print-color-adjust: exact;">
498 <?php echo esc_html($item['post_title']); ?>
499 <br>
500 <?php if (!empty($item['title'])) : ?>
501 <small style="font-size: 13px;color: #758195;">- <?php echo esc_html($item['title']); ?></small>
502 <br>
503 <?php endif; ?>
504 <?php if (!empty($item['payment_info'])) : ?>
505 <small style="font-size: 13px;color: #758195;"><?php echo esc_html($item['payment_info']); ?></small>
506 <?php endif; ?>
507 </td>
508 <td style="padding: 12px 8px;border: none;border-bottom: 1px solid #dee2e6;text-align: right;">
509 <?php echo esc_html(Helper::translateNumber($item['quantity'])); ?>
510 </td>
511 <td style="padding: 12px 8px;border: none;border-bottom: 1px solid #dee2e6;text-align: right">
512 <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice($item['unit_price'], null, false, true, true)); ?>
513 </td>
514 <td style="padding: 12px 8px;border: none;border-bottom: 1px solid #dee2e6;text-align: right">
515 <?php echo esc_html($item['formatted_total']); ?>
516 </td>
517 </tr>
518 <?php endforeach; ?>
519 </tbody>
520 </table>
521 <?php endif;
522 }
523
524 public function renderOrderItemsFooter()
525 {
526 $order = Arr::get($this->config, 'order', null);
527 ?>
528 <div
529 class="fct-receipt-page-order-items-footer"
530 style="margin-top: 20px;">
531 <table
532 class="fct-receipt-page-order-items-footer-table"
533 style="max-width: 250px;width: 100%;margin-left: auto;border-collapse: collapse;background: #f8f9fa;print-color-adjust: exact;border: none;">
534 <tbody>
535 <?php $this->renderSubtotal(); ?>
536 <?php $this->renderDiscount(); ?>
537 <?php $this->renderShipping(); ?>
538 <?php $this->renderFees(); ?>
539 <?php $this->renderTaxTotal(); ?>
540 <?php $this->renderShippingTax(); ?>
541 <?php $this->renderRefund(); ?>
542 <?php $this->renderTotal(); ?>
543 <?php $this->renderAmountPaid(); ?>
544 </tbody>
545 </table>
546 </div>
547 <?php
548 }
549
550 public function renderSubtotal()
551 {
552 $order = Arr::get($this->config, 'order', null);
553 if ($order->subtotal != ($order->total_amount - $order->total_refund) || $order->tax_total > 0): ?>
554 <tr>
555 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
556 <?php echo esc_html__('Subtotal', 'fluent-cart'); ?>
557 </td>
558 <td style="font-weight:700;padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
559 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->subtotal));
560 ?>
561 </td>
562 </tr>
563 <?php endif;
564 }
565
566 public function renderDiscount()
567 {
568 $order = Arr::get($this->config, 'order', null);
569 if ($order->manual_discount_total + $order->coupon_discount_total > 0): ?>
570 <tr>
571 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
572 <?php echo esc_html__('Discount', 'fluent-cart'); ?>
573 </td>
574 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
575 - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->manual_discount_total + $order->coupon_discount_total)); ?>
576 </td>
577 </tr>
578 <?php endif;
579 }
580
581 public function renderShipping()
582 {
583 $order = Arr::get($this->config, 'order', null);
584 if ($order->shipping_total > 0): ?>
585 <tr>
586 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
587 <?php echo esc_html__('Shipping', 'fluent-cart'); ?>
588 </td>
589 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
590 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->shipping_total)); ?>
591 </td>
592 </tr>
593 <?php endif;
594 }
595
596 public function renderFees()
597 {
598 $order = Arr::get($this->config, 'order', null);
599 if (!$order || $order->fee_total <= 0) {
600 return;
601 }
602 $feeItems = $order->feeItems()->get();
603 foreach ($feeItems as $feeItem): ?>
604 <tr>
605 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
606 <?php echo esc_html($feeItem->title); ?>
607 </td>
608 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
609 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($feeItem->subtotal)); ?>
610 </td>
611 </tr>
612 <?php endforeach;
613 }
614
615 public function renderTaxTotal()
616 {
617 $order = Arr::get($this->config, 'order', null);
618 if ($order->tax_total > 0): ?>
619 <tr>
620 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
621 <?php echo esc_html__('Tax', 'fluent-cart');
622 echo esc_html($order->tax_behavior == 2 ? __('(Included)', 'fluent-cart') : __('(Excluded)', 'fluent-cart'));
623 ?>
624 </td>
625 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
626 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->tax_total)); ?>
627 </td>
628 </tr>
629 <?php endif;
630 }
631
632 public function renderShippingTax()
633 {
634 $order = Arr::get($this->config, 'order', null);
635 if ($order->shipping_tax > 0): ?>
636 <tr>
637 <td style="padding: 8px 20px 8px 0;text-align: right;border: none;">
638 <?php echo esc_html__('Shipping Tax', 'fluent-cart');
639 echo esc_html($order->tax_behavior == 2 ? __('(Included)', 'fluent-cart') : __('(Excluded)', 'fluent-cart'));
640 ?>
641 </td>
642 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;">
643 <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->shipping_tax)); ?>
644 </td>
645 </tr>
646 <?php endif;
647 }
648
649 public function renderRefund()
650 {
651 $order = Arr::get($this->config, 'order', null);
652 if ($order->total_refund > 0): ?>
653 <tr style="font-weight: bold;font-size: 14px;">
654 <td style="font-weight:500;padding: 8px 20px 8px 0;text-align: right;border:none;">
655 <?php echo esc_html__('Refund', 'fluent-cart'); ?>
656 </td>
657 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border:none;">
658 - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->total_refund)); ?>
659 </td>
660 </tr>
661 <?php endif;
662 }
663
664 public function renderTotal()
665 {
666 $order = Arr::get($this->config, 'order', null);
667 ?>
668 <tr style="font-weight: bold;font-size: 14px;">
669 <td style="font-weight:500;padding: 8px 20px 8px 0;text-align: right;border:none;">
670 <?php echo esc_html__('Total', 'fluent-cart'); ?>
671 </td>
672 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border:none;">
673 <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice(($order->total_amount - $order->total_refund), null, false, true, true)); ?>
674 </td>
675 </tr>
676 <?php
677 }
678
679 public function renderAmountPaid()
680 {
681 $order = Arr::get($this->config, 'order', null);
682 ?>
683 <tr style="font-weight: bold;font-size: 14px;">
684 <td style="font-weight:500;padding: 8px 20px 8px 0;text-align: right;border:none;">
685 <?php echo esc_html__('Amount Paid', 'fluent-cart'); ?>
686 </td>
687 <td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border:none;">
688 <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice(($order->total_paid - $order->total_refund), null, false, true, true)); ?>
689 </td>
690 </tr>
691 <?php
692 }
693
694 public function renderTaxNote()
695 {
696 $order = Arr::get($this->config, 'order', null);
697 $orderTaxRates = $order->orderTaxRates->first();
698 $taxtotal = $order->tax_total + $order->shipping_tax;
699 if (Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.valid') && !$taxtotal): ?>
700
701 <div style="text-align: right; font-size: 14px; margin-top: 10px;">
702 <?php echo esc_html__('* Tax to be paid on reverse charge basis', 'fluent-cart'); ?>
703 </div>
704
705 <?php endif;
706 }
707
708 public function renderPaymentHistory()
709 {
710 $order = Arr::get($this->config, 'order', null);
711 $transactions = $order->transactions;
712 if (!empty($transactions)) :
713 ?>
714 <div
715 class="fct-payment-history"
716 style="margin-top: 30px;">
717 <div
718 class="fct-payment-history-heading"
719 style="font-weight: bold;font-size: 14px;color: #495057;margin: 0;padding: 0;">
720 <?php echo esc_html__('Payment history', 'fluent-cart'); ?>
721 </div>
722 <table class="fct-transaction-table"
723 style="margin-top: 10px;width: 100%;text-align: left;border-spacing: 0;border-collapse: collapse;border: none;">
724 <thead>
725 <tr>
726 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;print-color-adjust: exact;border:none;">
727 <?php echo esc_html__('Payment method', 'fluent-cart'); ?>
728 </th>
729 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold; text-align: center;print-color-adjust: exact;border:none;">
730 <?php echo esc_html__('Date', 'fluent-cart'); ?>
731 </th>
732 <th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold; text-align: right;print-color-adjust: exact;border:none;">
733 <?php echo esc_html__('Amount', 'fluent-cart'); ?>
734 </th>
735 </tr>
736 </thead>
737 <tbody>
738 <?php foreach ($transactions as $transaction) :
739 if ($transaction->transaction_type === 'refund') {
740 continue;
741 }
742 ?>
743 <tr>
744 <td style="padding: 10px;border:none;border-bottom: 1px solid #dee2e6;">
745 <?php echo esc_html($transaction->getPaymentMethodText()); ?>
746 </td>
747 <td style="padding: 10px;border:none;border-bottom: 1px solid #dee2e6;text-align: center;">
748 <?php
749 $date = wp_date(
750 get_option('date_format'),
751 DateTime::anyTimeToGmt($transaction->created_at)->getTimestamp(),
752 new \DateTimeZone($this->orderTz)
753 );
754 echo esc_html(Helper::translateNumber($date));
755 ?>
756 </td>
757 <td style="padding: 10px;border:none;border-bottom: 1px solid #dee2e6;text-align: right;">
758 <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice($transaction->total, null, false, true, true)); ?>
759 </td>
760 </tr>
761 <?php endforeach; ?>
762 </tbody>
763 </table>
764 </div>
765 <?php endif;
766 }
767
768 public function renderConfirmationError($errorData)
769 {
770 $failed_reason = Arr::get($errorData, 'failed_reason', '');
771 $custom_payment_url = Arr::get($errorData, 'custom_payment_url', '');
772 ?>
773 <style>
774 .fluent_cart_confirmation_failed {
775 max-width: 700px;
776 margin: 0 auto;
777 padding: 30px;
778 border-radius: 9px;
779 box-shadow: 1px 1px 5px 0px #ccc;
780 border-left: 3px solid red;
781 }
782 </style>
783 <div class="fluent_cart_confirmation_failed">
784 <h3><?php echo esc_html__('Payment Confirmation Failed!', 'fluent-cart'); ?></h3>
785 <span><?php echo esc_html__('We are sorry, your order is placed but payment confirmation has failed.', 'fluent-cart'); ?></span>
786 <?php if ($failed_reason) : ?>
787 <p style="color:red;font-style: italic;"><?php echo esc_html__('Failure reason: ', 'fluent-cart') . esc_html($failed_reason) ?></p>
788 <?php endif; ?>
789 <span><?php echo esc_html__('Please try to complete payment again from here!', 'fluent-cart'); ?></span>
790 <a href="<?php echo esc_url($custom_payment_url ?? ''); ?>"><?php echo esc_url($custom_payment_url); ?></a>
791 </div>
792 <?php }
793 }
794