PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.0
1.7.0 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 All 50 releases
← All changes | app/Services/Renderer/Receipt/ThankYouRender.php +279 -159 1.4.2 → 1.7.0 View file →
@@ -4,8 +4,9 @@
4 4
5 5 use FluentCart\Api\StoreSettings;
6 6 use FluentCart\App\App;
7 7 use FluentCart\App\Helpers\Helper;
8 +use FluentCart\App\Helpers\Status;
8 9 use FluentCart\App\Modules\Tax\TaxModule;
9 10 use FluentCart\App\Modules\Templating\AssetLoader;
10 11 use FluentCart\App\Vite;
11 12 use FluentCart\Framework\Support\Arr;
@@ -21,8 +22,9 @@
21 22 protected $is_first_time = false;
22 23
23 24 protected $order_operation = null;
24 25
26 + private $fctTaxSummaryCache = [];
25 27
26 28 public function __construct($config)
27 29 {
28 30 $this->config = $config;
@@ -34,8 +36,20 @@
34 36 AssetLoader::enqueueThankYouPageAssets();
35 37
36 38 }
37 39
40 + private function getMemoizedTaxSummary($order)
41 + {
42 + if (!$order) {
43 + return TaxSummaryHelper::computeTaxSummary($order);
44 + }
45 + $id = (int) $order->id;
46 + if (!isset($this->fctTaxSummaryCache[$id])) {
47 + $this->fctTaxSummaryCache[$id] = TaxSummaryHelper::computeTaxSummary($order);
48 + }
49 + return $this->fctTaxSummaryCache[$id];
50 + }
51 +
38 52 public function renderWrapperStart()
39 53 {
40 54 ?>
41 55 <div class="fct-thank-you-page">
@@ -92,47 +106,79 @@
92 106 ]);
93 107 }
94 108 }
95 109
110 + protected function getHeaderState()
111 + {
112 + $order = Arr::get($this->config, 'order', null);
113 + $status = $order ? $order->payment_status : '';
114 +
115 + if ($status === Status::PAYMENT_REFUNDED) {
116 + return 'refunded';
117 + }
118 + if ($status === Status::PAYMENT_FAILED) {
119 + return 'failed';
120 + }
121 + if (in_array($status, [Status::PAYMENT_PAID, Status::PAYMENT_PARTIALLY_REFUNDED], true)) {
122 + return 'success';
123 + }
124 +
125 + return 'pending';
126 + }
127 +
96 128 public function renderHeader()
97 129 {
98 - $bgColor = '#d4edda';
99 - $titleColor = '#155724';
100 - $iconBg = '#155724bd';
130 + $state = $this->getHeaderState();
101 131
102 - $order = Arr::get($this->config, 'order', null);
132 + $styles = [
133 + 'success' => ['bg' => '#d4edda', 'title' => '#155724', 'iconBg' => '#155724bd'],
134 + 'pending' => ['bg' => '#fff3cd', 'title' => '#856404', 'iconBg' => '#856404bd'],
135 + 'failed' => ['bg' => '#f8d7da', 'title' => '#721c24', 'iconBg' => '#721c24bd'],
136 + 'refunded' => ['bg' => '#e2e3e5', 'title' => '#383d41', 'iconBg' => '#383d41bd'],
137 + ];
103 138
104 - if ($order->payment_status !== 'paid') {
105 - $bgColor = '#fff3cd';
106 - $titleColor = '#856404';
107 - $iconBg = '#856404bd';
108 - }
139 + $titles = [
140 + 'success' => __('Purchase Successful!', 'fluent-cart'),
141 + 'pending' => __('Payment Pending!', 'fluent-cart'),
142 + 'failed' => __('Payment Failed', 'fluent-cart'),
143 + 'refunded' => __('Order Refunded', 'fluent-cart'),
144 + ];
145 +
146 + $bgColor = $styles[$state]['bg'];
147 + $titleColor = $styles[$state]['title'];
148 + $iconBg = $styles[$state]['iconBg'];
109 149 ?>
110 150 <div class="fct-thank-you-page-header" style="background: <?php echo esc_attr($bgColor); ?>;">
111 - <?php if ($order->payment_status !== 'paid') : ?>
112 - <div class="fct-thank-you-page-header-icon" style="background: <?php echo esc_attr($iconBg); ?>;">
151 + <div class="fct-thank-you-page-header-icon" style="background: <?php echo esc_attr($iconBg); ?>;">
152 + <?php if ($state === 'success') : ?>
153 + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
154 + stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
155 + <polyline points="20,6 9,17 4,12"></polyline>
156 + </svg>
157 + <?php elseif ($state === 'failed') : ?>
158 + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
159 + stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
160 + <line x1="18" y1="6" x2="6" y2="18"></line>
161 + <line x1="6" y1="6" x2="18" y2="18"></line>
162 + </svg>
163 + <?php elseif ($state === 'refunded') : ?>
164 + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
165 + stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
166 + <polyline points="9,14 4,9 9,4"></polyline>
167 + <path d="M4 9h10a6 6 0 0 1 0 12h-3"></path>
168 + </svg>
169 + <?php else : ?>
113 170 <svg class="w-64 h-64" xmlns="http://www.w3.org/2000/svg"
114 171 viewBox="0 0 1024 1024" fill="currentColor">
115 172 <path
116 173 d="M480 674V192c0-18 14-32 32-32s32 14 32 32v482h-64zm0 63h64v60h-64v-60zM0 512C0 229 229 0 512 0s512 229 512 512-229 512-512 512S0 795 0 512zm961 0c0-247-202-448-449-448S64 265 64 512s201 448 448 448 449-201 449-448z"></path>
117 174 </svg>
118 - </div>
119 - <h1 class="fct-thank-you-page-header-title" style="color:<?php echo esc_attr($titleColor); ?>">
120 - <?php echo esc_html__('Payment Pending!', 'fluent-cart'); ?>
121 - </h1>
175 + <?php endif; ?>
176 + </div>
177 + <h1 class="fct-thank-you-page-header-title" style="color:<?php echo esc_attr($titleColor); ?>;">
178 + <?php echo esc_html($titles[$state]); ?>
179 + </h1>
122 180
123 - <?php else: ?>
124 - <div class="fct-thank-you-page-header-icon" style="background: <?php echo esc_attr($iconBg); ?>;">
125 - <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
126 - stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
127 - <polyline points="20,6 9,17 4,12"></polyline>
128 - </svg>
129 - </div>
130 - <h1 class="fct-thank-you-page-header-title" style="color:<?php echo esc_attr($titleColor); ?>;">
131 - <?php echo esc_html__('Purchase Successful!', 'fluent-cart'); ?>
132 - </h1>
133 - <?php endif; ?>
134 -
135 181 <?php do_action('fluent_cart/receipt/thank_you/after_header_title', $this->config); ?>
136 182
137 183 </div>
138 184
@@ -193,9 +239,10 @@
193 239 esc_html($order->customer->full_name)
194 240 );
195 241 ?>
196 242 </div>
197 - <?php if ($order->payment_status === 'paid') : ?>
243 + <?php $state = $this->getHeaderState(); ?>
244 + <?php if ($state === 'success') : ?>
198 245 <p>
199 246 <?php
200 247 printf(
201 248 '%s<strong style="color: #007bff;"><a href="%s">#%s</a></strong>%s',
@@ -205,8 +252,34 @@
205 252 esc_html__(' has been placed successfully.', 'fluent-cart')
206 253 );
207 254 ?>
208 255 </p>
256 + <?php elseif ($state === 'refunded') : ?>
257 + <p>
258 + <?php
259 + printf(
260 + '%s<strong style="color: #007bff;"><a href="%s">#%s</a></strong>%s',
261 + esc_html__('Your order ', 'fluent-cart'),
262 + esc_url($profilePage . 'order/' . $order->uuid),
263 + esc_html($order->invoice_no),
264 + esc_html__(' has been refunded.', 'fluent-cart')
265 + );
266 + ?>
267 + </p>
268 + <?php elseif ($state === 'failed') : ?>
269 + <p>
270 + <?php
271 + printf(
272 + '%s<strong style="color: #007bff;"><a href="%s">#%s</a></strong>%s <a style="color: #007bff;" target="_blank" href="%s">%s</a>.',
273 + esc_html__('The payment for your order ', 'fluent-cart'),
274 + esc_url($profilePage . 'order/' . $order->uuid),
275 + esc_html($order->invoice_no),
276 + esc_html__(' could not be completed. You can try again from', 'fluent-cart'),
277 + esc_url(\FluentCart\App\Services\Payments\PaymentHelper::getCustomPaymentLink($order->uuid)),
278 + esc_html__('here', 'fluent-cart')
279 + );
280 + ?>
281 + </p>
209 282 <?php else: ?>
210 283 <p>
211 284
212 285 <?php
@@ -277,8 +350,9 @@
277 350
278 351 public function renderOrderItemsBody()
279 352 {
280 353 $order = Arr::get($this->config, 'order', null);
354 + $fctTaxDisplayMode = TaxSummaryHelper::getTaxDisplayMode();
281 355 ?>
282 356 <div class="fct-thank-you-page-order-items-body">
283 357 <?php
284 358 $order->loadMissing(['order_items']);
@@ -285,9 +359,8 @@
285 359 $orderItems = $order->getProductItems()->toArray();
286 360 $orderItems = $this->buildBundleItemsTree($orderItems);
287 361
288 362 foreach ($orderItems as $item) :
289 -
290 363 ?>
291 364 <div class="fct-thank-you-page-order-items-list">
292 365 <div class="fct-thank-you-page-order-items-list-title">
293 366 <p class="fct-thank-you-page-order-items-list-quantity">
@@ -295,11 +368,13 @@
295 368 <?php if ($item['quantity'] > 1): ?>
296 369 <span>x <?php echo esc_html(Helper::translateNumber($item['quantity'])); ?></span>
297 370 <?php endif; ?>
298 371 </p>
299 - <p class="fct-thank-you-page-order-items-list-variant-title">
300 - - <?php echo esc_html($item['title']); ?>
301 - </p>
372 + <?php if (!empty($item['title']) && $item['title'] !== $item['post_title']): ?>
373 + <p class="fct-thank-you-page-order-items-list-variant-title">
374 + - <?php echo esc_html(!empty($item['variation_display_title']) ? $item['variation_display_title'] : $item['title']); ?>
375 + </p>
376 + <?php endif; ?>
302 377 <?php if ($item['payment_type'] === 'subscription' && !empty($item['payment_info'])): ?>
303 378 <p class="fct-thank-you-page-order-items-list-payment-info">
304 379 <?php echo wp_kses_post($item['payment_info']) ?>
305 380 </p>
@@ -313,9 +388,11 @@
313 388 </div>
314 389 </div>
315 390
316 391 <div class="fct-thank-you-page-order-items-tax-info">
317 - <?php $this->renderItemTaxPill($item, $order); ?>
392 + <?php if ($fctTaxDisplayMode !== 'simplified'): ?>
393 + <?php $this->renderItemTaxPill($item, $order); ?>
394 + <?php endif; ?>
318 395 <?php if (!empty($item['setup_info'])): ?>
319 396 <div class="fct-thank-you-page-order-items-setup-fee">
320 397 <div class="setup-fee">
321 398 <?php echo esc_html(Arr::get($item, 'other_info.signup_fee_name', '')); ?>
@@ -325,9 +402,11 @@
325 402 <?php echo esc_html(Helper::toDecimal(Arr::get($item, 'other_info.signup_fee', ''))); ?>
326 403 </div>
327 404 </div>
328 405 <?php endif; ?>
329 - <?php $this->renderItemSetupFeeTaxPills($item, $order); ?>
406 + <?php if ($fctTaxDisplayMode !== 'simplified'): ?>
407 + <?php $this->renderItemSetupFeeTaxPills($item, $order); ?>
408 + <?php endif; ?>
330 409 </div>
331 410 <?php endforeach; ?>
332 411
333 412 <?php $this->renderOrderTotal(); ?>
@@ -391,9 +470,9 @@
391 470 {
392 471 $order = Arr::get($this->config, 'order', null);
393 472 if ($order->isReverseChargeTaxOrder()): ?>
394 473 <div style="text-align: right; font-size: 14px; margin-top: 10px;">
395 - <?php echo '*' . esc_html__('Tax to be paid on reverse charge basis', 'fluent-cart') ?>
474 + <?php echo '*' . esc_html(TaxModule::getReverseChargeNoticeText()) ?>
396 475 </div>
397 476 <?php
398 477 endif;
399 478 }
@@ -465,17 +544,21 @@
465 544 return;
466 545 }
467 546 $displayShipping = (int) $order->shipping_total;
468 547 if ($order->isReverseChargeTaxOrder()) {
469 - $rcAdj = (int) Arr::get(TaxSummaryHelper::computeTaxSummary($order), 'rcShippingAdjustment', 0);
548 + $rcAdj = (int) Arr::get($this->getMemoizedTaxSummary($order), 'rcShippingAdjustment', 0);
470 549 if ($rcAdj > 0) {
471 550 $displayShipping = max(0, $displayShipping - $rcAdj);
472 551 }
473 552 }
553 + $shippingMethodTitle = (string) Arr::get($order->config, 'shipping_method_title', '');
474 554 ?>
475 555 <div class="fct-meta-line fct-thank-you-page-order-items-total-shipping">
476 556 <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
477 557 <?php echo esc_html__('Shipping', 'fluent-cart'); ?>
558 + <?php if ($shippingMethodTitle): ?>
559 + <span class="fct-shipping-method-name"><?php echo esc_html($shippingMethodTitle); ?></span>
560 + <?php endif; ?>
478 561 </div>
479 562 <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value"><?php echo esc_html(Helper::toDecimal($displayShipping)); ?></div>
480 563 </div>
481 564 <?php
@@ -499,64 +582,8 @@
499 582 </div>
500 583 <?php endforeach;
501 584 }
502 585
503 - public function renderTaxTotal()
504 - {
505 - $order = Arr::get($this->config, 'order', null);
506 -
507 - if ($order->isReverseChargeTaxOrder()): ?>
508 - <?php
509 - $rcReversedTotal = $order->getReversedTaxTotal();
510 - $rcChargeLabel = $rcReversedTotal > 0
511 - ? sprintf(
512 - /* translators: %1$s: formatted reversed tax amount */
513 - __('Tax reversed: %1$s', 'fluent-cart'),
514 - Helper::toDecimal($rcReversedTotal)
515 - )
516 - : __('Charge reversed', 'fluent-cart');
517 - ?>
518 - <div class="fct-meta-line fct-thank-you-page-order-items-total-tax">
519 - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
520 - <?php echo esc_html__('Tax', 'fluent-cart'); ?>
521 - </div>
522 - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value">
523 - <?php echo esc_html($rcChargeLabel); ?>
524 - </div>
525 - </div>
526 - <?php elseif ($order->tax_total > 0): ?>
527 - <div class="fct-meta-line fct-thank-you-page-order-items-total-tax">
528 - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
529 - <?php echo esc_html__('Total Tax', 'fluent-cart'); ?>
530 - <?php echo \FluentCart\App\Helpers\Helper::getOrderTaxLabel($order); ?>
531 - </div>
532 - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value">
533 - <?php echo esc_html(Helper::toDecimal($order->tax_total)); ?>
534 - </div>
535 - </div>
536 - <?php endif;
537 - }
538 -
539 - public function renderShippingTax()
540 - {
541 - $order = Arr::get($this->config, 'order', null);
542 -
543 - if ($order->shipping_tax <= 0) {
544 - return;
545 - }
546 - ?>
547 - <div class="fct-meta-line fct-thank-you-page-order-items-total-shipping-tax">
548 - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
549 - <?php echo esc_html__('Shipping Tax', 'fluent-cart'); ?>
550 - <?php echo \FluentCart\App\Helpers\Helper::getOrderTaxLabel($order); ?>
551 - </div>
552 - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value">
553 - <?php echo esc_html(Helper::toDecimal($order->shipping_tax)); ?>
554 - </div>
555 - </div>
556 - <?php
557 - }
558 -
559 586 public function renderRefund()
560 587 {
561 588 $order = Arr::get($this->config, 'order', null);
562 589
@@ -576,9 +603,9 @@
576 603 {
577 604 $order = Arr::get($this->config, 'order', null);
578 605 $displayTotal = (int) $order->total_amount - (int) $order->total_refund;
579 606 if ($order->isReverseChargeTaxOrder()) {
580 - $rcAdj = (int) Arr::get(TaxSummaryHelper::computeTaxSummary($order), 'rcTotalAdjustment', 0);
607 + $rcAdj = (int) Arr::get($this->getMemoizedTaxSummary($order), 'rcTotalAdjustment', 0);
581 608 if ($rcAdj > 0) {
582 609 $displayTotal = max(0, $displayTotal - $rcAdj);
583 610 }
584 611 }
@@ -636,9 +663,9 @@
636 663 <?php foreach ($subscriptions as $subs): ?>
637 664 <tr>
638 665 <td class="fct-thank-you-page-order-items-subscriptions-table-file">
639 666 <p>
640 - <?php echo esc_html($subs->item_name); ?>
667 + <?php echo esc_html($subs->display_item_name); ?>
641 668 </p>
642 669 </td>
643 670
644 671 <td class="fct-thank-you-page-order-items-subscriptions-billing-infos">
@@ -654,9 +681,9 @@
654 681 echo sprintf(
655 682 /* translators: 1: Next billing date */
656 683 esc_html__('- Auto renews on %1$s', 'fluent-cart'),
657 684 esc_html(
658 - \FluentCart\App\Services\DateTime\DateTime::gmtToTimezone($subs->next_billing_date)->format('M d, Y h:i A')
685 + \FluentCart\App\Services\DateTime\DateFormatter::format($subs->next_billing_date, true, $order)
659 686 )
660 687 );
661 688 ?>
662 689 </p>
@@ -1110,17 +1137,51 @@
1110 1137
1111 1138 public function renderTaxSummaryBox()
1112 1139 {
1113 1140 $order = Arr::get($this->config, 'order', null);
1114 - $summary = TaxSummaryHelper::computeTaxSummary($order);
1141 + $summary = $this->getMemoizedTaxSummary($order);
1115 1142 if (!$summary['shouldRender']) {
1116 1143 return;
1117 1144 }
1145 +
1146 + $tyIsSimplified = (($summary['displayMode'] ?? '') === 'simplified') && !empty($summary['simpleLine']);
1147 +
1148 + if ($tyIsSimplified) :
1149 + ?>
1150 + <div class="fct-meta-line fct-thank-you-tax-simple-line">
1151 + <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label fct-thank-you-tax-simple-label">
1152 + <span><?php echo esc_html($summary['simpleLine']['label']); ?></span>
1153 + <?php if (!empty($summary['simpleLine']['hasDetails'])) : ?>
1154 + <details class="fct-thank-you-tax-details">
1155 + <summary class="fct-thank-you-tax-toggle"><?php echo esc_html__('See details', 'fluent-cart'); ?> &#9662;</summary>
1156 + <div class="fct-thank-you-tax-summary fct-thank-you-tax-floating">
1157 + <?php $this->renderTaxBreakdownCardInner($summary); ?>
1158 + </div>
1159 + </details>
1160 + <?php endif; ?>
1161 + </div>
1162 + <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value"><?php echo esc_html($summary['simpleLine']['value']); ?></div>
1163 + </div>
1164 + <?php
1165 + else :
1166 + ?>
1167 + <div class="fct-thank-you-tax-summary">
1168 + <?php $this->renderTaxBreakdownCardInner($summary); ?>
1169 + </div>
1170 + <?php
1171 + endif;
1172 + }
1173 +
1174 + private function renderTaxBreakdownCardInner($summary)
1175 + {
1118 1176 ?>
1119 - <div class="fct-thank-you-tax-summary">
1120 1177 <div class="fct-thank-you-tax-summary-header">
1121 1178 <span class="fct-thank-you-tax-summary-title">
1122 - <?php echo esc_html__('TAX SUMMARY', 'fluent-cart'); ?>
1179 + <?php if (!empty(Arr::get($summary, 'foldedRateLines', []))): ?>
1180 + <?php echo esc_html__('Tax breakdown by rate', 'fluent-cart'); ?>
1181 + <?php else: ?>
1182 + <?php echo esc_html__('TAX SUMMARY', 'fluent-cart'); ?>
1183 + <?php endif; ?>
1123 1184 </span>
1124 1185 <span class="fct-item-tax-hint" tabindex="0"
1125 1186 aria-label="<?php echo esc_attr__('Tax breakdown explanation', 'fluent-cart'); ?>">
1126 1187 <span class="fct-item-tax-hint-icon">i</span>
@@ -1129,16 +1190,59 @@
1129 1190 </span>
1130 1191 </span>
1131 1192 </div>
1132 1193
1133 - <?php if ($summary['isReverseCharge']): ?>
1194 + <?php
1195 + $tyFoldedRateLines = Arr::get($summary, 'foldedRateLines', []);
1196 + $tyIsReverseCharge = !empty($summary['isReverseCharge']);
1197 + $rcReversedTotal = (int) Arr::get($summary, 'reversedTaxTotal', 0);
1198 + $rcReversedShipping = (int) Arr::get($summary, 'reversedShippingTax', 0);
1199 + $rcReversedValue = $rcReversedTotal > 0
1200 + ? Helper::toDecimal($rcReversedTotal)
1201 + : __('Charge reversed', 'fluent-cart');
1202 + ?>
1203 + <?php if (!empty($tyFoldedRateLines)): ?>
1134 1204 <?php
1135 - $rcReversedTotal = (int) Arr::get($summary, 'reversedTaxTotal', 0);
1136 - $rcReversedShipping = (int) Arr::get($summary, 'reversedShippingTax', 0);
1137 - $rcReversedValue = $rcReversedTotal > 0
1138 - ? Helper::toDecimal($rcReversedTotal)
1139 - : __('Charge reversed', 'fluent-cart');
1205 + $tyIncludedInPrices = (int) Arr::get($summary, 'includedInPrices', 0);
1206 + $tyPayableTax = (int) Arr::get($summary, 'payableTax', 0);
1207 + $tyTotalOrderTax = (int) Arr::get($summary, 'totalOrderTax', 0);
1140 1208 ?>
1209 + <div style="display:grid;grid-template-columns:minmax(0,1fr) 92px 64px;column-gap:12px;align-items:start;">
1210 + <span style="min-width:0;font-size:11px;text-transform:uppercase;letter-spacing:0.04em;color:#94a3b8;"><?php echo esc_html__('Rate', 'fluent-cart'); ?></span>
1211 + <span style="text-align:right;font-size:11px;text-transform:uppercase;letter-spacing:0.04em;color:#94a3b8;white-space:nowrap;"><?php echo esc_html__('Taxable base', 'fluent-cart'); ?></span>
1212 + <span style="text-align:right;font-size:11px;text-transform:uppercase;letter-spacing:0.04em;color:#94a3b8;white-space:nowrap;"><?php echo esc_html__('Tax', 'fluent-cart'); ?></span>
1213 + </div>
1214 + <?php foreach ($tyFoldedRateLines as $tyFoldedLine): ?>
1215 + <div class="fct-thank-you-tax-summary-row<?php echo !empty($tyFoldedLine['inclusive']) ? ' fct-thank-you-tax-summary-row--muted' : ''; ?>" style="display:grid;grid-template-columns:minmax(0,1fr) 92px 64px;column-gap:12px;align-items:start;">
1216 + <span style="min-width:0;white-space:normal;overflow-wrap:anywhere;word-break:break-word;"><?php echo esc_html($tyFoldedLine['label']); ?></span>
1217 + <span style="text-align:right;color:#94a3b8;white-space:nowrap;"><?php echo esc_html(Helper::toDecimal($tyFoldedLine['base'])); ?></span>
1218 + <span style="text-align:right;white-space:nowrap;"><?php echo esc_html(Helper::toDecimal($tyFoldedLine['tax'])); ?></span>
1219 + </div>
1220 + <?php endforeach; ?>
1221 + <?php if ($tyIsReverseCharge): ?>
1222 + <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--total">
1223 + <span><?php echo esc_html__('VAT reversed', 'fluent-cart'); ?></span>
1224 + <span><?php echo esc_html($rcReversedValue); ?></span>
1225 + </div>
1226 + <?php else: ?>
1227 + <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--total">
1228 + <span><?php echo esc_html__('Total tax', 'fluent-cart'); ?></span>
1229 + <span><?php echo esc_html(Helper::toDecimal($tyTotalOrderTax)); ?></span>
1230 + </div>
1231 + <?php if ($tyIncludedInPrices > 0): ?>
1232 + <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--muted">
1233 + <span><?php echo esc_html__('of which included in prices', 'fluent-cart'); ?></span>
1234 + <span><?php echo esc_html(Helper::toDecimal($tyIncludedInPrices)); ?></span>
1235 + </div>
1236 + <?php endif; ?>
1237 + <?php if ($tyPayableTax > 0 && $tyIncludedInPrices > 0): ?>
1238 + <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--total">
1239 + <span><?php echo esc_html__('Payable now (added)', 'fluent-cart'); ?></span>
1240 + <span><?php echo esc_html(Helper::toDecimal($tyPayableTax)); ?></span>
1241 + </div>
1242 + <?php endif; ?>
1243 + <?php endif; ?>
1244 + <?php elseif ($tyIsReverseCharge): ?>
1141 1245 <?php if ($summary['showRcShippingRow'] && $rcReversedShipping > 0): ?>
1142 1246 <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--muted">
1143 1247 <span><?php echo esc_html__('Added on shipping', 'fluent-cart'); ?></span>
1144 1248 <span style="text-decoration:line-through;opacity:0.6;"><?php echo esc_html(Helper::toDecimal($rcReversedShipping)); ?></span>
@@ -1149,70 +1253,86 @@
1149 1253 <span><?php echo esc_html($rcReversedValue); ?></span>
1150 1254 </div>
1151 1255 <?php else: ?>
1152 1256 <?php
1153 - $tyFeeRows = Arr::get($summary, 'feeTaxLineRows', []);
1154 - $rowCount = (int) ($summary['inclusiveTax'] > 0) + (int) ($summary['exclusiveTax'] > 0) + count($tyFeeRows) + (int) ($summary['shippingTax'] > 0);
1155 - $shouldShowBreakdown = $rowCount >= 2 || ($rowCount === 1 && !($summary['payableTax'] > 0 || $summary['inclusiveTax'] > 0 || (int) Arr::get($summary, 'inclusiveFeeTax', 0) > 0));
1257 + $tyFeeRows = Arr::get($summary, 'feeTaxLineRows', []);
1258 + $taxRateLines = Arr::get($summary, 'taxRateLines', []);
1259 + $shippingTaxLines = Arr::get($summary, 'shippingTaxLines', []);
1156 1260 ?>
1157 - <?php if ($summary['inclusiveTax'] > 0 && $shouldShowBreakdown): ?>
1158 - <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--muted">
1159 - <span><?php echo esc_html__('Included in item prices', 'fluent-cart'); ?></span>
1160 - <span><?php echo esc_html(Helper::toDecimal($summary['inclusiveTax'])); ?></span>
1261 + <?php
1262 + $productTaxRowCount = !empty($taxRateLines)
1263 + ? count($taxRateLines)
1264 + : (int) ($summary['inclusiveTax'] > 0) + (int) ($summary['exclusiveTax'] > 0);
1265 + $rowCount = $productTaxRowCount + count($tyFeeRows) + (int) ($summary['shippingTax'] > 0);
1266 + $shouldShowBreakdown = !empty($taxRateLines)
1267 + || !empty($shippingTaxLines)
1268 + || $rowCount >= 2
1269 + || ($rowCount === 1 && !($summary['payableTax'] > 0 || $summary['inclusiveTax'] > 0 || (int) Arr::get($summary, 'inclusiveFeeTax', 0) > 0));
1270 + ?>
1271 + <?php if (!empty($taxRateLines) && $shouldShowBreakdown): ?>
1272 + <?php foreach ($taxRateLines as $taxLine) : ?>
1273 + <div class="fct-thank-you-tax-summary-row<?php echo !empty($taxLine['inclusive']) ? ' fct-thank-you-tax-summary-row--muted' : ''; ?>">
1274 + <span><?php echo esc_html($taxLine['label']); ?></span>
1275 + <span><?php echo esc_html(Helper::toDecimal($taxLine['order_tax'])); ?></span>
1276 + </div>
1277 + <?php endforeach; ?>
1278 + <?php endif; ?>
1279 + <?php if (empty($taxRateLines) && $summary['inclusiveTax'] > 0 && $shouldShowBreakdown): ?>
1280 + <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--muted">
1281 + <span><?php echo esc_html__('Included in item prices', 'fluent-cart'); ?></span>
1282 + <span><?php echo esc_html(Helper::toDecimal($summary['inclusiveTax'])); ?></span>
1283 + </div>
1284 + <?php endif; ?>
1285 + <?php if (empty($taxRateLines) && $summary['exclusiveTax'] > 0 && $shouldShowBreakdown): ?>
1286 + <div class="fct-thank-you-tax-summary-row">
1287 + <span><?php echo esc_html__('Added on products', 'fluent-cart'); ?></span>
1288 + <span><?php echo esc_html(Helper::toDecimal($summary['exclusiveTax'])); ?></span>
1289 + </div>
1290 + <?php endif; ?>
1291 + <?php if ($shouldShowBreakdown) : ?>
1292 + <?php foreach ($tyFeeRows as $feeRow) : ?>
1293 + <div class="fct-thank-you-tax-summary-row<?php echo $feeRow['inclusive'] ? ' fct-thank-you-tax-summary-row--muted' : ''; ?>">
1294 + <span><?php echo esc_html($feeRow['display_label']); ?></span>
1295 + <span><?php echo esc_html(Helper::toDecimal($feeRow['tax_amount'])); ?></span>
1161 1296 </div>
1162 - <?php endif; ?>
1163 - <?php if ($summary['exclusiveTax'] > 0 && $shouldShowBreakdown): ?>
1164 - <div class="fct-thank-you-tax-summary-row">
1165 - <span><?php echo esc_html__('Added on products', 'fluent-cart'); ?></span>
1166 - <span><?php echo esc_html(Helper::toDecimal($summary['exclusiveTax'])); ?></span>
1167 - </div>
1168 - <?php endif; ?>
1169 - <?php if ($shouldShowBreakdown) : ?>
1170 - <?php foreach ($tyFeeRows as $feeRow) : ?>
1171 - <div class="fct-thank-you-tax-summary-row<?php echo $feeRow['inclusive'] ? ' fct-thank-you-tax-summary-row--muted' : ''; ?>">
1172 - <span><?php echo esc_html($feeRow['display_label']); ?></span>
1173 - <span><?php echo esc_html(Helper::toDecimal($feeRow['tax_amount'])); ?></span>
1174 - </div>
1175 - <?php endforeach; ?>
1176 - <?php endif; ?>
1177 - <?php if ($summary['shippingTax'] > 0 && $shouldShowBreakdown):
1178 - $isShippingInclusive = (bool) Arr::get($summary, 'isShippingInclusive', false);
1179 - $shippingTaxLines = Arr::get($summary, 'shippingTaxLines', []);
1180 - $shippingRowClass = 'fct-thank-you-tax-summary-row' . ($isShippingInclusive ? ' fct-thank-you-tax-summary-row--muted' : '');
1181 - if (!empty($shippingTaxLines)):
1182 - foreach ($shippingTaxLines as $shLine): ?>
1297 + <?php endforeach; ?>
1298 + <?php endif; ?>
1299 + <?php if ($summary['shippingTax'] > 0 && $shouldShowBreakdown):
1300 + $isShippingInclusive = (bool) Arr::get($summary, 'isShippingInclusive', false);
1301 + $shippingRowClass = 'fct-thank-you-tax-summary-row' . ($isShippingInclusive ? ' fct-thank-you-tax-summary-row--muted' : '');
1302 + if (!empty($shippingTaxLines)):
1303 + foreach ($shippingTaxLines as $shLine): ?>
1304 + <div class="<?php echo esc_attr($shippingRowClass); ?>">
1305 + <span><?php echo esc_html($shLine['label']); ?></span>
1306 + <span><?php echo esc_html(Helper::toDecimal($shLine['shipping_tax'])); ?></span>
1307 + </div>
1308 + <?php endforeach;
1309 + else: ?>
1183 1310 <div class="<?php echo esc_attr($shippingRowClass); ?>">
1184 - <span><?php echo esc_html($shLine['label']); ?></span>
1185 - <span><?php echo esc_html(Helper::toDecimal($shLine['shipping_tax'])); ?></span>
1311 + <span>
1312 + <?php if ($isShippingInclusive): ?>
1313 + <?php echo esc_html__('Included in shipping prices', 'fluent-cart'); ?>
1314 + <?php else: ?>
1315 + <?php echo esc_html__('Added on shipping', 'fluent-cart'); ?>
1316 + <?php endif; ?>
1317 + </span>
1318 + <span><?php echo esc_html(Helper::toDecimal($summary['shippingTax'])); ?></span>
1186 1319 </div>
1187 - <?php endforeach;
1188 - else: ?>
1189 - <div class="<?php echo esc_attr($shippingRowClass); ?>">
1190 - <span>
1191 - <?php if ($isShippingInclusive): ?>
1192 - <?php echo esc_html__('Included in shipping prices', 'fluent-cart'); ?>
1193 - <?php else: ?>
1194 - <?php echo esc_html__('Added on shipping', 'fluent-cart'); ?>
1195 - <?php endif; ?>
1196 - </span>
1197 - <span><?php echo esc_html(Helper::toDecimal($summary['shippingTax'])); ?></span>
1320 + <?php endif; ?>
1321 + <?php endif; ?>
1322 + <?php if ($summary['payableTax'] > 0): ?>
1323 + <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--total">
1324 + <span><?php echo esc_html__('Total payable tax', 'fluent-cart'); ?></span>
1325 + <span><?php echo esc_html(Helper::toDecimal($summary['payableTax'])); ?></span>
1198 1326 </div>
1199 1327 <?php endif; ?>
1328 + <?php if ($summary['inclusiveTax'] > 0 || $summary['inclusiveFeeTax'] > 0): ?>
1329 + <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--muted">
1330 + <span><?php echo esc_html__('Total tax in this order', 'fluent-cart'); ?></span>
1331 + <span><?php echo esc_html(Helper::toDecimal($summary['totalOrderTax'])); ?></span>
1332 + </div>
1333 + <?php endif; ?>
1200 1334 <?php endif; ?>
1201 - <?php if ($summary['payableTax'] > 0): ?>
1202 - <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--total">
1203 - <span><?php echo esc_html__('Total payable tax', 'fluent-cart'); ?></span>
1204 - <span><?php echo esc_html(Helper::toDecimal($summary['payableTax'])); ?></span>
1205 - </div>
1206 - <?php endif; ?>
1207 - <?php if ($summary['inclusiveTax'] > 0 || $summary['inclusiveFeeTax'] > 0): ?>
1208 - <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--muted">
1209 - <span><?php echo esc_html__('Total tax in this order', 'fluent-cart'); ?></span>
1210 - <span><?php echo esc_html(Helper::toDecimal($summary['totalOrderTax'])); ?></span>
1211 - </div>
1212 - <?php endif; ?>
1213 - <?php endif; ?>
1214 - </div>
1215 1335 <?php
1216 1336 }
1217 1337
1218 1338 public function renderItemTaxPill($item, $order)