PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.1
1.7.1 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 All 51 releases
← All changes | app/Services/Renderer/Receipt/ThankYouRender.php +623 -178 1.3.26 → 1.7.1 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">
@@ -79,60 +93,92 @@
79 93
80 94 $this->renderFooter();
81 95
82 96 do_action('fluent_cart/after_receipt', [
83 - 'order' => $order,
84 - 'is_first_time' => $this->is_first_time ?? false,
85 - 'order_operation' => $this->order_operation ?? null
97 + 'order' => $order,
98 + 'is_first_time' => $this->is_first_time ?? false,
99 + 'order_operation' => $this->order_operation ?? null
86 100 ]);
87 101
88 102 if (!empty($this->is_first_time)) {
89 103 do_action('fluent_cart/after_receipt_first_time', [
90 - 'order' => $order,
91 - 'order_operation' => $this->order_operation ?? null
104 + 'order' => $order,
105 + 'order_operation' => $this->order_operation ?? null
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
@@ -187,37 +233,64 @@
187 233 <div class="no-print">
188 234 <div class="no-print-title">
189 235 <?php
190 236 echo sprintf(
191 - /* translators: %s is the customer's full name */
192 - esc_html__('Hello %s!', 'fluent-cart'),
193 - esc_html($order->customer->full_name)
237 + /* translators: %s is the customer's full name */
238 + esc_html__('Hello %s!', 'fluent-cart'),
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 - '%s<strong style="color: #007bff;"><a href="%s">#%s</a></strong>%s',
202 - esc_html__('Your order ', 'fluent-cart'),
203 - esc_url($profilePage . 'order/' . $order->uuid),
204 - esc_html($order->invoice_no),
205 - esc_html__(' has been placed successfully.', 'fluent-cart')
248 + '%s<strong style="color: #007bff;"><a href="%s">#%s</a></strong>%s',
249 + esc_html__('Your order ', 'fluent-cart'),
250 + esc_url($profilePage . 'order/' . $order->uuid),
251 + esc_html($order->invoice_no),
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
213 286 printf(
214 - '<strong style="color: #007bff;"><a href="%s">%s</a></strong> %s <a style="color: #007bff;" target="_blank" href="%s">%s</a>.',
215 - esc_url($profilePage . 'order/' . $order->uuid),
216 - esc_html__('Your order', 'fluent-cart'),
217 - esc_html__('has payment due. You can pay from', 'fluent-cart'),
218 - esc_url(\FluentCart\App\Services\Payments\PaymentHelper::getCustomPaymentLink($order->uuid)),
219 - esc_html__('here', 'fluent-cart')
287 + '<strong style="color: #007bff;"><a href="%s">%s</a></strong> %s <a style="color: #007bff;" target="_blank" href="%s">%s</a>.',
288 + esc_url($profilePage . 'order/' . $order->uuid),
289 + esc_html__('Your order', 'fluent-cart'),
290 + esc_html__('has payment due. You can pay from', 'fluent-cart'),
291 + esc_url(\FluentCart\App\Services\Payments\PaymentHelper::getCustomPaymentLink($order->uuid)),
292 + esc_html__('here', 'fluent-cart')
220 293 );
221 294 ?>
222 295
223 296 </p>
@@ -231,9 +304,9 @@
231 304 public function renderStoreTaxInformation()
232 305 {
233 306 $order = Arr::get($this->config, 'order', null);
234 307
235 - $orderTaxRates = $order->orderTaxRates->first();
308 + $orderTaxRates = $order->getPrimaryOrderTaxRate();
236 309 if ($order->tax_total > 0 || $orderTaxRates): ?>
237 310 <div class="fct_invoice_tax_content">
238 311 <?php
239 312 if ($orderTaxRates) {
@@ -277,11 +350,13 @@
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
358 + $order->loadMissing(['order_items']);
284 359 $orderItems = $order->getProductItems()->toArray();
285 360 $orderItems = $this->buildBundleItemsTree($orderItems);
286 361
287 362 foreach ($orderItems as $item) :
@@ -293,22 +368,18 @@
293 368 <?php if ($item['quantity'] > 1): ?>
294 369 <span>x <?php echo esc_html(Helper::translateNumber($item['quantity'])); ?></span>
295 370 <?php endif; ?>
296 371 </p>
297 - <p class="fct-thank-you-page-order-items-list-variant-title">
298 - - <?php echo esc_html($item['title']); ?>
299 - </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; ?>
300 377 <?php if ($item['payment_type'] === 'subscription' && !empty($item['payment_info'])): ?>
301 378 <p class="fct-thank-you-page-order-items-list-payment-info">
302 379 <?php echo wp_kses_post($item['payment_info']) ?>
303 380 </p>
304 381 <?php endif; ?>
305 - <?php if (!empty($item['setup_info'])): ?>
306 - <p class="fct-thank-you-page-order-items-list-payment-info">
307 - <?php echo wp_kses_post($item['setup_info']); ?>
308 - </p>
309 - <?php endif; ?>
310 -
311 382 <?php $this->renderBundleProducts($item); ?>
312 383 </div>
313 384 <div class="fct-thank-you-page-order-items-list-price">
314 385 <div class="fct-thank-you-page-order-items-list-price-inner">
@@ -316,9 +387,27 @@
316 387 </div>
317 388 </div>
318 389 </div>
319 390
391 + <div class="fct-thank-you-page-order-items-tax-info">
392 + <?php if ($fctTaxDisplayMode !== 'simplified'): ?>
393 + <?php $this->renderItemTaxPill($item, $order); ?>
394 + <?php endif; ?>
395 + <?php if (!empty($item['setup_info'])): ?>
396 + <div class="fct-thank-you-page-order-items-setup-fee">
397 + <div class="setup-fee">
398 + <?php echo esc_html(Arr::get($item, 'other_info.signup_fee_name', '')); ?>
399 + </div>
320 400
401 + <div class="setup-fee-amount">
402 + <?php echo esc_html(Helper::toDecimal(Arr::get($item, 'other_info.signup_fee', ''))); ?>
403 + </div>
404 + </div>
405 + <?php endif; ?>
406 + <?php if ($fctTaxDisplayMode !== 'simplified'): ?>
407 + <?php $this->renderItemSetupFeeTaxPills($item, $order); ?>
408 + <?php endif; ?>
409 + </div>
321 410 <?php endforeach; ?>
322 411
323 412 <?php $this->renderOrderTotal(); ?>
324 413
@@ -334,9 +423,11 @@
334 423 $order = Arr::get($this->config, 'order', null);
335 424 if (!$order) {
336 425 return;
337 426 }
338 - $transaction = $order->getLatestTransaction();
427 + $transaction = $order->getLatestTransaction();
428 + $methodSlug = '';
429 + $thankYouPageInstructions = '';
339 430 if ($transaction && !empty($transaction->payment_method)) {
340 431 $methodSlug = $transaction->payment_method;
341 432 }
342 433 if (GatewayManager::has($methodSlug)) {
@@ -341,9 +432,9 @@
341 432 }
342 433 if (GatewayManager::has($methodSlug)) {
343 434 $gatewayInstance = GatewayManager::getInstance($methodSlug);
344 435 if ($gatewayInstance && isset($gatewayInstance->settings)) {
345 - $gatewaySettings = (array) $gatewayInstance->settings->get();
436 + $gatewaySettings = (array) $gatewayInstance->settings->get();
346 437 $thankYouPageInstructions = Arr::get($gatewaySettings, 'thank_you_page_instructions', '');
347 438 }
348 439 }
349 440
@@ -349,9 +440,9 @@
349 440
350 441 if (!empty($thankYouPageInstructions)) : ?>
351 442
352 443 <div style="max-width: 620px; margin: 15px auto 0; font-family: Arial, Helvetica, sans-serif;">
353 - <div style="font-size: 14px; color: #2F3448; padding: 12px 0; border-top: 1px solid #e7eaee;">
444 + <div style="font-size: 14px; color: var(--fct-primary-text-color, currentColor); padding: 12px 0; border-top: 1px solid var(--fct-divider-color, #e7eaee);">
354 445 <?php echo wp_kses_post($thankYouPageInstructions); ?>
355 446 </div>
356 447 </div>
357 448 <?php endif;
@@ -364,11 +455,11 @@
364 455 <?php $this->renderSubtotal(); ?>
365 456 <?php $this->renderDiscount(); ?>
366 457 <?php $this->renderShipping(); ?>
367 458 <?php $this->renderFees(); ?>
368 - <?php $this->renderTaxTotal(); ?>
369 - <?php $this->renderShippingTax(); ?>
459 + <?php $this->renderTaxSummaryBox(); ?>
370 460
461 + <?php $this->renderProrateCredit(); ?>
371 462 <?php $this->renderRefund(); ?>
372 463 <?php $this->renderTotal(); ?>
373 464 <?php $this->renderPaymentMethod(); ?>
374 465 </div>
@@ -377,12 +468,11 @@
377 468
378 469 public function renderTaxNote()
379 470 {
380 471 $order = Arr::get($this->config, 'order', null);
381 - $taxtotal = $order->tax_total + $order->shipping_tax;
382 - if (Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.valid') && !$taxtotal): ?>
472 + if ($order->isReverseChargeTaxOrder()): ?>
383 473 <div style="text-align: right; font-size: 14px; margin-top: 10px;">
384 - <?php echo '*' . esc_html__('Tax to be paid on reverse charge basis', 'fluent-cart') ?>
474 + <?php echo '*' . esc_html(TaxModule::getReverseChargeNoticeText()) ?>
385 475 </div>
386 476 <?php
387 477 endif;
388 478 }
@@ -402,33 +492,77 @@
402 492
403 493 public function renderDiscount()
404 494 {
405 495 $order = Arr::get($this->config, 'order', null);
496 + $prorateCredit = (int) Arr::get($order->config, 'prorate_credit', 0);
497 + $upgradeDiscount = $order->manual_discount_total - $prorateCredit;
498 + // When the prorate credit IS the whole discount, label the row directly
499 + // instead of showing "Discount" with a single redundant breakdown row.
500 + $onlyProrateCredit = $prorateCredit > 0 && $upgradeDiscount <= 0 && $order->coupon_discount_total <= 0;
406 501
407 502 if ($order->manual_discount_total + $order->coupon_discount_total > 0): ?>
408 - <div class="fct-meta-line fct-thank-you-page-order-items-total-discount">
409 - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
410 - <?php echo esc_html__('Discount', 'fluent-cart'); ?>
411 - </div>
412 - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value">
413 - - <?php echo esc_html(Helper::toDecimal($order->manual_discount_total + $order->coupon_discount_total)); ?>
414 - </div>
503 + <div class="fct-meta-line fct-thank-you-page-order-items-total-discount">
504 + <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
505 + <?php echo $onlyProrateCredit ? esc_html__('Prorate Credit', 'fluent-cart') : esc_html__('Discount', 'fluent-cart'); ?>
415 506 </div>
507 + <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value">
508 + - <?php echo esc_html(Helper::toDecimal($order->manual_discount_total + $order->coupon_discount_total)); ?>
509 + </div>
510 + </div>
511 + <?php if ($prorateCredit > 0 && $upgradeDiscount > 0): ?>
512 + <div class="fct-meta-line" style="padding-left:12px;">
513 + <div class="fct-meta-line-label" style="font-size:12px;color:var(--fct-secondary-text-color, rgb(107,114,128));">
514 + <?php echo esc_html__('Upgrade Discount', 'fluent-cart'); ?>
515 + </div>
516 + <div class="fct-meta-line-value" style="font-size:12px;color:var(--fct-secondary-text-color, rgb(107,114,128));">
517 + <?php echo esc_html(Helper::toDecimal($upgradeDiscount)); ?>
518 + </div>
519 + </div>
520 + <?php endif; ?>
521 + <?php if ($prorateCredit > 0 && !$onlyProrateCredit): ?>
522 + <div class="fct-meta-line" style="padding-left:12px;">
523 + <div class="fct-meta-line-label" style="font-size:12px;color:var(--fct-secondary-text-color, rgb(107,114,128));">
524 + <?php echo esc_html__('Prorate Credit', 'fluent-cart'); ?>
525 + </div>
526 + <div class="fct-meta-line-value" style="font-size:12px;color:var(--fct-secondary-text-color, rgb(107,114,128));">
527 + <?php echo esc_html(Helper::toDecimal($prorateCredit)); ?>
528 + </div>
529 + </div>
530 + <?php endif; ?>
416 531 <?php endif;
417 532 }
418 533
534 + public function renderProrateCredit()
535 + {
536 + // Rendered as a sub-row inside renderDiscount.
537 + }
538 +
419 539 public function renderShipping()
420 540 {
421 541 $order = Arr::get($this->config, 'order', null);
422 542
423 - if ($order->shipping_total > 0): ?>
424 - <div class="fct-meta-line fct-thank-you-page-order-items-total-shipping">
425 - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
426 - <?php echo esc_html__('Shipping', 'fluent-cart'); ?>
427 - </div>
428 - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value"><?php echo esc_html(Helper::toDecimal($order->shipping_total)); ?></div>
543 + if ($order->shipping_total <= 0) {
544 + return;
545 + }
546 + $displayShipping = (int) $order->shipping_total;
547 + if ($order->isReverseChargeTaxOrder()) {
548 + $rcAdj = (int) Arr::get($this->getMemoizedTaxSummary($order), 'rcShippingAdjustment', 0);
549 + if ($rcAdj > 0) {
550 + $displayShipping = max(0, $displayShipping - $rcAdj);
551 + }
552 + }
553 + $shippingMethodTitle = (string) Arr::get($order->config, 'shipping_method_title', '');
554 + ?>
555 + <div class="fct-meta-line fct-thank-you-page-order-items-total-shipping">
556 + <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
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; ?>
429 561 </div>
430 - <?php endif;
562 + <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value"><?php echo esc_html(Helper::toDecimal($displayShipping)); ?></div>
563 + </div>
564 + <?php
431 565 }
432 566
433 567 public function renderFees()
434 568 {
@@ -448,42 +582,8 @@
448 582 </div>
449 583 <?php endforeach;
450 584 }
451 585
452 - public function renderTaxTotal()
453 - {
454 - $order = Arr::get($this->config, 'order', null);
455 -
456 - if ($order->tax_total > 0): ?>
457 - <div class="fct-meta-line fct-thank-you-page-order-items-total-tax">
458 - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
459 - <?php echo esc_html__('Total Tax', 'fluent-cart'); ?>
460 - <?php echo $order->tax_behavior == 2 ? esc_html__('(Included)', 'fluent-cart') : esc_html__('(Excluded)', 'fluent-cart'); ?>
461 - </div>
462 - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value">
463 - <?php echo esc_html(Helper::toDecimal($order->tax_total)); ?>
464 - </div>
465 - </div>
466 - <?php endif;
467 - }
468 -
469 - public function renderShippingTax()
470 - {
471 - $order = Arr::get($this->config, 'order', null);
472 -
473 - if ($order->shipping_tax > 0): ?>
474 - <div class="fct-meta-line fct-thank-you-page-order-items-total-shipping-tax">
475 - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
476 - <?php echo esc_html__('Shipping Tax', 'fluent-cart'); ?>
477 - <?php echo $order->tax_behavior == 2 ? esc_html__('(Included)', 'fluent-cart') : esc_html__('(Excluded)', 'fluent-cart'); ?>
478 - </div>
479 - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value">
480 - <?php echo esc_html(Helper::toDecimal($order->shipping_tax)); ?>
481 - </div>
482 - </div>
483 - <?php endif;
484 - }
485 -
486 586 public function renderRefund()
487 587 {
488 588 $order = Arr::get($this->config, 'order', null);
489 589
@@ -501,8 +601,15 @@
501 601
502 602 public function renderTotal()
503 603 {
504 604 $order = Arr::get($this->config, 'order', null);
605 + $displayTotal = (int) $order->total_amount - (int) $order->total_refund;
606 + if ($order->isReverseChargeTaxOrder()) {
607 + $rcAdj = (int) Arr::get($this->getMemoizedTaxSummary($order), 'rcTotalAdjustment', 0);
608 + if ($rcAdj > 0) {
609 + $displayTotal = max(0, $displayTotal - $rcAdj);
610 + }
611 + }
505 612 ?>
506 613 <div class="fct-meta-line fct-thank-you-page-order-items-total-total">
507 614 <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
508 615 <?php echo esc_html__('Total', 'fluent-cart'); ?>
@@ -507,9 +614,9 @@
507 614 <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label">
508 615 <?php echo esc_html__('Total', 'fluent-cart'); ?>
509 616 </div>
510 617 <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value">
511 - <?php echo esc_html(Helper::toDecimal($order->total_amount - $order->total_refund)); ?>
618 + <?php echo esc_html(Helper::toDecimal($displayTotal)); ?>
512 619 </div>
513 620 </div>
514 621 <?php
515 622 }
@@ -556,9 +663,9 @@
556 663 <?php foreach ($subscriptions as $subs): ?>
557 664 <tr>
558 665 <td class="fct-thank-you-page-order-items-subscriptions-table-file">
559 666 <p>
560 - <?php echo esc_html($subs->item_name); ?>
667 + <?php echo esc_html($subs->display_item_name); ?>
561 668 </p>
562 669 </td>
563 670
564 671 <td class="fct-thank-you-page-order-items-subscriptions-billing-infos">
@@ -571,12 +678,12 @@
571 678
572 679 <?php if (!empty($subs->next_billing_date)) : ?>
573 680 <p class="fct-thank-you-page-order-items-subscriptions-billing-infos-next-billing"><?php
574 681 echo sprintf(
575 - /* translators: 1: Next billing date */
682 + /* translators: 1: Next billing date */
576 683 esc_html__('- Auto renews on %1$s', 'fluent-cart'),
577 684 esc_html(
578 - \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)
579 686 )
580 687 );
581 688 ?>
582 689 </p>
@@ -621,9 +728,9 @@
621 728 <tr>
622 729 <td>
623 730 <?php if ($downloadItem['downloads']): ?>
624 731
625 - <table role="presentation">
732 + <table role="presentation" width="100%">
626 733 <tbody>
627 734 <?php foreach ($downloadItem['downloads'] as $download): ?>
628 735 <tr>
629 736 <td class="fct-thank-you-page-order-items-downloads-table-file">
@@ -666,13 +773,13 @@
666 773 {
667 774 $showNotice = $show_notice ?? true;
668 775 ?>
669 776 <?php if (!$showNotice) {
670 - return;
671 - } ?>
777 + return;
778 + } ?>
672 779 <table
673 - class="fct-thank-you-page-order-items-downloads-notice"
674 - role="presentation">
780 + class="fct-thank-you-page-order-items-downloads-notice"
781 + role="presentation">
675 782 <tbody>
676 783 <tr>
677 784 <td>
678 785 <p class="fct-thank-you-page-order-items-downloads-notice-title">
@@ -693,13 +800,13 @@
693 800 {
694 801 $showNotice = $show_notice ?? true;
695 802 ?>
696 803 <?php if (!$showNotice) {
697 - return;
698 - } ?>
804 + return;
805 + } ?>
699 806 <table
700 - class="fct-thank-you-page-order-items-downloads-notice"
701 - role="presentation">
807 + class="fct-thank-you-page-order-items-downloads-notice"
808 + role="presentation">
702 809 <tbody>
703 810 <tr>
704 811 <td>
705 812 <p class="fct-thank-you-page-order-items-downloads-notice-title">
@@ -758,14 +865,16 @@
758 865
759 866 public function renderAddress()
760 867 {
761 868 $order = Arr::get($this->config, 'order', null);
762 - if ($order->fulfillment_type === 'physical') : ?>
763 - <div class="fct-thank-you-page-order-items-addresses">
764 - <?php $this->renderBillToAddress(); ?>
869 + ?>
870 + <div class="fct-thank-you-page-order-items-addresses">
871 + <?php $this->renderBillToAddress(); ?>
872 + <?php if ($order->fulfillment_type === 'physical') : ?>
765 873 <?php $this->renderShipToAddress(); ?>
766 - </div>
767 - <?php endif;
874 + <?php endif; ?>
875 + </div>
876 + <?php
768 877 }
769 878
770 879 public function renderBillToAddress()
771 880 {
@@ -800,26 +909,52 @@
800 909 <div class="fct-thank-you-page-order-items-addresses-bill-to-phone">
801 910 <?php echo esc_html($phoneNumber); ?>
802 911 </div>
803 912 <?php endif; ?>
804 - <div class="fct-thank-you-page-order-items-addresses-bill-to-company-name">
805 - <?php
806 - $companyName = Arr::get($order->billing_address->meta ?? [], 'other_data.company_name', '');
807 -
808 - if ($companyName === '') {
809 - $companyName = Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.name', '');
810 - }
811 - echo esc_html($companyName);
913 + <?php
914 + $companyName = $order->billing_address
915 + ? Arr::get($order->billing_address->meta ?? [], 'other_data.company_name', '')
916 + : '';
917 + if ($companyName === '') {
918 + $companyName = $order->getCustomerTaxName();
919 + }
920 + if ($companyName !== ''):
812 921 ?>
813 - </div>
922 + <div class="fct-thank-you-page-order-items-addresses-bill-to-company-name">
923 + <?php echo esc_html($companyName); ?>
924 + </div>
925 + <?php endif; ?>
926 + <?php
927 + $legalRegId = $order->billing_address
928 + ? Arr::get($order->billing_address->meta ?? [], 'other_data.legal_registration_id', '')
929 + : '';
930 + if ($legalRegId === '') {
931 + $legalRegId = Arr::get($order->getBusinessInfo(), 'legal_registration_id', '');
932 + }
933 + if ($legalRegId !== ''):
934 + ?>
935 + <div class="fct-thank-you-page-order-items-addresses-bill-to-legal-reg">
936 + <?php echo esc_html__('Reg. ID', 'fluent-cart') . ': ' . esc_html($legalRegId); ?>
937 + </div>
938 + <?php endif; ?>
814 939 <div class="fct-thank-you-page-order-items-addresses-bill-to-vat-number">
815 940 <?php
816 - $vatNumber = Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.vat_number', '');
941 + $vatNumber = $order->getCustomerTaxNumber();
817 942 if ($vatNumber !== '') {
818 - echo esc_html__('EU VAT', 'fluent-cart') . ': ' . esc_html($vatNumber);
943 + $vatLabel = __('VAT/Tax ID', 'fluent-cart');
944 + echo esc_html($vatLabel) . ': ' . esc_html($vatNumber);
819 945 }
820 946 ?>
821 947 </div>
948 + <?php
949 + $reverseChargeDeclaration = Arr::get($order->getBusinessInfo(), 'reverse_charge_declaration', '');
950 + if ($reverseChargeDeclaration !== ''):
951 + ?>
952 + <div class="fct-thank-you-page-order-items-addresses-bill-to-reverse-charge">
953 + <strong><?php echo esc_html__('Reverse Charge Declaration', 'fluent-cart'); ?>:</strong>
954 + <?php echo esc_html($reverseChargeDeclaration); ?>
955 + </div>
956 + <?php endif; ?>
822 957 </div>
823 958 <?php
824 959 }
825 960
@@ -873,10 +1008,10 @@
873 1008 $profilePage = $this->settings->getCustomerProfilePage();
874 1009
875 1010 ?>
876 1011 <a
877 - class="fct-thank-you-page-view-order-button"
878 - href="<?php echo esc_url($profilePage . 'order/' . $order->uuid); ?>">
1012 + class="fct-thank-you-page-view-order-button"
1013 + href="<?php echo esc_url($profilePage . 'order/' . $order->uuid); ?>">
879 1014 <?php echo esc_html__('View Order', 'fluent-cart'); ?>
880 1015 </a>
881 1016 <?php
882 1017 }
@@ -885,17 +1020,17 @@
885 1020 {
886 1021 $order = Arr::get($this->config, 'order', null);
887 1022 ?>
888 1023 <a
889 - class="fct-thank-you-page-download-receipt-button"
890 - href="<?php echo esc_url(\FluentCart\App\Services\URL::appendQueryParams(
891 - home_url(),
892 - [
893 - 'fluent-cart' => 'receipt',
894 - 'order_hash' => $order->uuid,
895 - 'download' => 1
896 - ]
897 - )) ?>">
1024 + class="fct-thank-you-page-download-receipt-button"
1025 + href="<?php echo esc_url(\FluentCart\App\Services\URL::appendQueryParams(
1026 + home_url(),
1027 + [
1028 + 'fluent-cart' => 'receipt',
1029 + 'order_hash' => $order->uuid,
1030 + 'download' => 1
1031 + ]
1032 + )) ?>">
898 1033 <?php echo esc_html__('Download Receipt', 'fluent-cart'); ?>
899 1034 </a>
900 1035 <?php
901 1036 }
@@ -953,35 +1088,35 @@
953 1088 }
954 1089
955 1090 $total = count($item['bundle_items']);
956 1091 ?>
957 - <div class="fct-bundle-products" data-fluent-cart-collapsibles>
958 - <h4 class="fct-bundle-products-title">
959 - <?php echo esc_html__('Bundle of', 'fluent-cart') . ':'; ?>
960 - </h4>
1092 + <div class="fct-bundle-products" data-fluent-cart-collapsibles>
1093 + <h4 class="fct-bundle-products-title">
1094 + <?php echo esc_html__('Bundle of', 'fluent-cart') . ':'; ?>
1095 + </h4>
961 1096
962 - <div class="fct-bundle-products-list">
963 - <?php foreach (array_slice($item['bundle_items'], 0, 2) as $bundleItem): ?>
964 - <p>
965 - <?php echo esc_html(Arr::get($bundleItem, 'title', '')); ?>
966 - </p>
967 - <?php endforeach; ?>
1097 + <div class="fct-bundle-products-list">
1098 + <?php foreach (array_slice($item['bundle_items'], 0, 2) as $bundleItem): ?>
1099 + <p>
1100 + <?php echo esc_html(Arr::get($bundleItem, 'title', '')); ?>
1101 + </p>
1102 + <?php endforeach; ?>
968 1103
969 - <?php if ($total > 2): ?>
970 - <div class="fct-bundle-products-more">
971 - <div class="fct-bundle-products-more-list">
972 - <?php foreach (array_slice($item['bundle_items'], 2) as $bundleItem): ?>
973 - <p>
974 - <?php echo esc_html(Arr::get($bundleItem, 'title', '')); ?>
975 - </p>
976 - <?php endforeach; ?>
977 - </div>
1104 + <?php if ($total > 2): ?>
1105 + <div class="fct-bundle-products-more">
1106 + <div class="fct-bundle-products-more-list">
1107 + <?php foreach (array_slice($item['bundle_items'], 2) as $bundleItem): ?>
1108 + <p>
1109 + <?php echo esc_html(Arr::get($bundleItem, 'title', '')); ?>
1110 + </p>
1111 + <?php endforeach; ?>
978 1112 </div>
979 - <?php endif; ?>
980 - </div>
1113 + </div>
1114 + <?php endif; ?>
1115 + </div>
981 1116
982 - <?php if ($total > 2) : ?>
983 - <a href="#" class="fct-see-more-btn" data-fluent-cart-collapsible-toggle>
1117 + <?php if ($total > 2) : ?>
1118 + <a href="#" class="fct-see-more-btn" data-fluent-cart-collapsible-toggle>
984 1119 <span class="see-more-text">
985 1120 <?php echo esc_html__('See More', 'fluent-cart'); ?>
986 1121 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="7" viewBox="0 0 12 7" fill="none">
987 1122 <path d="M0.75 0.75L5.04289 5.04289C5.37623 5.37623 5.54289 5.54289 5.75 5.54289C5.95711 5.54289 6.12377 5.37623 6.45711 5.04289L10.75 0.75" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
@@ -987,17 +1122,327 @@
987 1122 <path d="M0.75 0.75L5.04289 5.04289C5.37623 5.37623 5.54289 5.54289 5.75 5.54289C5.95711 5.54289 6.12377 5.37623 6.45711 5.04289L10.75 0.75" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
988 1123 </svg>
989 1124 </span>
990 1125
991 - <span class="see-less-text">
1126 + <span class="see-less-text">
992 1127 <?php echo esc_html__('See Less', 'fluent-cart'); ?>
993 1128 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="7" viewBox="0 0 14 8" fill="none">
994 1129 <path d="M0.75 6.54297L6.04289 1.25008C6.37623 0.916742 6.54289 0.750076 6.75 0.750076C6.95711 0.750076 7.12377 0.916742 7.45711 1.25008L12.75 6.54297" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
995 1130 </svg>
996 1131 </span>
997 - </a>
1132 + </a>
1133 + <?php endif; ?>
1134 + </div>
1135 + <?php
1136 + }
1137 +
1138 + public function renderTaxSummaryBox()
1139 + {
1140 + $order = Arr::get($this->config, 'order', null);
1141 + $summary = $this->getMemoizedTaxSummary($order);
1142 + if (!$summary['shouldRender']) {
1143 + return;
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 + {
1176 + ?>
1177 + <div class="fct-thank-you-tax-summary-header">
1178 + <span class="fct-thank-you-tax-summary-title">
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; ?>
1184 + </span>
1185 + <span class="fct-item-tax-hint" tabindex="0"
1186 + aria-label="<?php echo esc_attr__('Tax breakdown explanation', 'fluent-cart'); ?>">
1187 + <span class="fct-item-tax-hint-icon">i</span>
1188 + <span class="fct-item-tax-hint-tooltip">
1189 + <?php echo esc_html__('Inclusive tax is embedded in item prices. Exclusive tax is added on top.', 'fluent-cart'); ?>
1190 + </span>
1191 + </span>
1192 + </div>
1193 +
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)): ?>
1204 + <?php
1205 + $tyIncludedInPrices = (int) Arr::get($summary, 'includedInPrices', 0);
1206 + $tyPayableTax = (int) Arr::get($summary, 'payableTax', 0);
1207 + $tyTotalOrderTax = (int) Arr::get($summary, 'totalOrderTax', 0);
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; ?>
998 1243 <?php endif; ?>
1244 + <?php elseif ($tyIsReverseCharge): ?>
1245 + <?php if ($summary['showRcShippingRow'] && $rcReversedShipping > 0): ?>
1246 + <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--muted">
1247 + <span><?php echo esc_html__('Added on shipping', 'fluent-cart'); ?></span>
1248 + <span style="text-decoration:line-through;opacity:0.6;"><?php echo esc_html(Helper::toDecimal($rcReversedShipping)); ?></span>
1249 + </div>
1250 + <?php endif; ?>
1251 + <div class="fct-thank-you-tax-summary-row fct-thank-you-tax-summary-row--total">
1252 + <span><?php echo esc_html__('Tax reversed', 'fluent-cart'); ?></span>
1253 + <span><?php echo esc_html($rcReversedValue); ?></span>
1254 + </div>
1255 + <?php else: ?>
1256 + <?php
1257 + $tyFeeRows = Arr::get($summary, 'feeTaxLineRows', []);
1258 + $taxRateLines = Arr::get($summary, 'taxRateLines', []);
1259 + $shippingTaxLines = Arr::get($summary, 'shippingTaxLines', []);
1260 + ?>
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>
1296 + </div>
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: ?>
1310 + <div class="<?php echo esc_attr($shippingRowClass); ?>">
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>
1319 + </div>
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>
1326 + </div>
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; ?>
1334 + <?php endif; ?>
1335 + <?php
1336 + }
1337 +
1338 + public function renderItemTaxPill($item, $order)
1339 + {
1340 + $rates = TaxSummaryHelper::getItemTaxRates($item);
1341 + $isReversed = $order->isReverseChargeTaxOrder();
1342 + $rcMode = $order->getOrderRcMode();
1343 +
1344 + if (!empty($rates)) {
1345 + $this->renderTaxRatePills($rates, $isReversed, $rcMode);
1346 + return;
1347 + }
1348 +
1349 + // Fallback: existing aggregate pill for old orders without tax_config
1350 + $taxAmount = (int) ($item['tax_amount'] ?? 0);
1351 + if ($taxAmount <= 0) {
1352 + return;
1353 + }
1354 + $isInclusive = TaxSummaryHelper::isPrimaryTaxInclusive($order);
1355 + $pillClass = $isInclusive ? 'fct-tax-pill--inclusive' : 'fct-tax-pill--exclusive';
1356 + $reversedClass = ($isReversed && (!$isInclusive || $rcMode === 'dynamic')) ? ' is-reversed' : '';
1357 + ?>
1358 + <div class="fct-item-tax-pills">
1359 + <div class="fct-item-tax-pill-row">
1360 + <span class="fct-tax-pill <?php echo esc_attr($pillClass); ?>">
1361 + <?php echo $isInclusive ? esc_html__('Incl.', 'fluent-cart') : esc_html__('Add.', 'fluent-cart'); ?>
1362 + </span>
1363 + <span class="fct-item-tax-pill-amount <?php echo esc_attr(($isInclusive ? 'is-inclusive' : 'is-exclusive') . $reversedClass); ?>">
1364 + <?php if ($isInclusive): ?>
1365 + <?php echo esc_html__('incl.', 'fluent-cart'); ?> <?php echo esc_html(Helper::toDecimal($taxAmount)); ?>
1366 + <?php else: ?>
1367 + + <?php echo esc_html(Helper::toDecimal($taxAmount)); ?>
1368 + <?php endif; ?>
1369 + </span>
999 1370 </div>
1371 + </div>
1372 + <?php
1373 + }
1374 +
1375 + public function renderItemSetupFeeTaxPills($item, $order)
1376 + {
1377 + $isSubscription = $item['payment_type'] === 'subscription'
1378 + || !empty(Arr::get($item, 'other_info.signup_fee'));
1379 +
1380 + if (!$isSubscription) {
1381 + return;
1382 + }
1383 +
1384 + $isReversed = $order->isReverseChargeTaxOrder();
1385 + $rcMode = $order->getOrderRcMode();
1386 + $signupFeeItem = null;
1387 + if ($order->order_items) {
1388 + $signupFeeItem = $order->order_items
1389 + ->where('payment_type', 'signup_fee')
1390 + ->where('object_id', $item['object_id'])
1391 + ->first();
1392 + }
1393 +
1394 + if ($signupFeeItem) {
1395 + $rates = TaxSummaryHelper::getItemTaxRates($signupFeeItem->toArray());
1396 + if (!empty($rates)) {
1397 + $this->renderTaxRatePills($rates, $isReversed, $rcMode);
1398 + return;
1399 + }
1400 + }
1401 +
1402 + $signupFeeTax = (int) Arr::get($item, 'other_info.signup_fee_tax', 0);
1403 + if ($signupFeeTax <= 0) {
1404 + return;
1405 + }
1406 + $sfIsInclusive = TaxSummaryHelper::isPrimaryTaxInclusive($order);
1407 + $reversedClass = ($isReversed && (!$sfIsInclusive || $rcMode === 'dynamic')) ? ' is-reversed' : '';
1408 + ?>
1409 + <div class="fct-item-tax-pills">
1410 + <div class="fct-item-tax-pill-row">
1411 + <span class="fct-item-tax-pill-amount<?php echo esc_attr($reversedClass); ?>"><?php
1412 + /* translators: %1$s: formatted setup fee tax amount */
1413 + echo sprintf(esc_html__('Setup fee tax: %1$s', 'fluent-cart'), esc_html(Helper::toDecimal($signupFeeTax)));
1414 + ?></span>
1415 + </div>
1416 + </div>
1417 + <?php
1418 + }
1419 +
1420 + private function renderTaxRatePills(array $rates, bool $isReversed = false, string $rcMode = 'fixed')
1421 + {
1422 + ?>
1423 + <div class="fct-item-tax-pills">
1424 + <?php foreach ($rates as $rate) : ?>
1425 + <?php
1426 + $pillClass = $rate['inclusive'] ? 'fct-tax-pill--inclusive' : 'fct-tax-pill--exclusive';
1427 + $percent = rtrim(rtrim(number_format($rate['rate_percent'], 3, '.', ''), '0'), '.');
1428 + $rateIsInclusive = !empty($rate['inclusive']);
1429 + $rateReversedClass = ($isReversed && (!$rateIsInclusive || $rcMode === 'dynamic')) ? ' is-reversed' : '';
1430 + ?>
1431 + <div class="fct-item-tax-pill-row">
1432 + <span class="fct-tax-pill <?php echo esc_attr($pillClass); ?>">
1433 + <?php echo esc_html($rate['label']) . ' (' . esc_html($percent) . '%)'; ?>
1434 + </span>
1435 + <span class="fct-item-tax-pill-amount <?php echo esc_attr(($rate['inclusive'] ? 'is-inclusive' : 'is-exclusive') . $rateReversedClass); ?>">
1436 + <?php if ($rate['inclusive']): ?>
1437 + <?php echo esc_html__('incl.', 'fluent-cart'); ?> <?php echo esc_html(Helper::toDecimal($rate['tax_amount'])); ?>
1438 + <?php else: ?>
1439 + + <?php echo esc_html(Helper::toDecimal($rate['tax_amount'])); ?>
1440 + <?php endif; ?>
1441 + </span>
1442 + </div>
1443 + <?php endforeach; ?>
1444 + </div>
1000 1445 <?php
1001 1446 }
1002 1447
1003 1448 }