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/Views/emails/parts/items_table.php +570 -38 1.3.22 → 1.7.1 View file →
@@ -14,8 +14,10 @@
14 14
15 15 <?php
16 16
17 17 use FluentCart\Framework\Support\Arr;
18 +use FluentCart\App\Modules\Tax\TaxModule;
19 +use FluentCart\App\Services\Renderer\Receipt\TaxSummaryHelper;
18 20 $allOrderItems = $order->order_items ? $order->order_items->toArray() : [];
19 21 $orderItems = array_filter($allOrderItems, function ($item) {
20 22 return !in_array($item['payment_type'] ?? '', ['signup_fee', 'fee']);
21 23 });
@@ -23,8 +25,11 @@
23 25 return ($item['payment_type'] ?? '') === 'fee';
24 26 });
25 27 $transaction = $order->getLatestTransaction();
26 28 $isRefund = $is_refund ?? false;
29 + $isReversed = $order->isReverseChargeTaxOrder();
30 + $rcMode = $order->getOrderRcMode();
31 + $fctEmailDisplayMode = ($order instanceof \FluentCart\App\Models\Order) ? TaxSummaryHelper::getTaxDisplayMode() : 'itemized';
27 32
28 33 ?>
29 34
30 35 <table role="presentation" style="border-spacing:0;padding: 0; width: 100%;border: none">
@@ -56,9 +61,9 @@
56 61 <span style="font-size:12px;font-weight:400;color:rgb(75,85,99)">x <?php echo esc_html($item['quantity']); ?></span>
57 62 <?php endif; ?>
58 63
59 64 <p style="margin: 0; font-size: 14px; color: #758195; font-weight: 400; line-height: 15px;">
60 - - <?php echo esc_html($item['title']); ?>
65 + - <?php echo esc_html(!empty($item['variation_display_title']) ? $item['variation_display_title'] : $item['title']); ?>
61 66 </p>
62 67
63 68 <?php if ($item['payment_type'] === 'subscription' && !empty($item['payment_info'])): ?>
64 69 <p style="font-size:12px;color:rgb(75,85,99);line-height:20px;margin: 3px 0 0 0;">
@@ -65,13 +70,15 @@
65 70 <?php echo wp_kses_post($item['payment_info']) ?>
66 71 </p>
67 72 <?php endif; ?>
68 73
74 +
75 +
69 76 <?php
70 77 $otherInfo = is_array($item['other_info'] ?? null) ? $item['other_info'] : [];
71 78 $packageInfo = Arr::get($item, 'package_info', '');
72 79 if (!$packageInfo && Arr::get($otherInfo, 'package_name')) {
73 - $packageInfo = \FluentCart\App\Services\Renderer\ProductCardRender::buildPackageInfoFromOtherInfo($otherInfo);
80 + $packageInfo = \FluentCart\App\Services\Renderer\PackageDescriptionRenderer::buildPackageInfoFromOtherInfo($otherInfo);
74 81 }
75 82 if ($packageInfo):
76 83 ?>
77 84 <p style="font-size:12px;color:rgb(107,114,128);line-height:18px;margin: 5px 0 0 0;">
@@ -85,18 +92,198 @@
85 92 <?php echo esc_html($item['formatted_total']); ?>
86 93 </p>
87 94 </td>
88 95 </tr>
96 +
97 + <?php
98 + $itemRates = TaxSummaryHelper::getItemTaxRates($item);
99 + ?>
100 + <?php if ($fctEmailDisplayMode !== 'simplified' && !empty($itemRates)): ?>
101 + <tr>
102 + <td colspan="3" style="padding: 0 16px 8px;">
103 + <table width="100%" style="border-spacing:0;border-collapse:collapse;">
104 + <?php foreach ($itemRates as $rate):
105 + $pillBg = $rate['inclusive'] ? '#EAF3DE' : '#FAEEDA';
106 + $pillColor = $rate['inclusive'] ? '#3B6D11' : '#854F0B';
107 + $rateIsInclusive = !empty($rate['inclusive']);
108 + $reversedAmountStyle = ($isReversed && (!$rateIsInclusive || $rcMode === 'dynamic')) ? 'text-decoration:line-through;opacity:0.6;' : '';
109 + ?>
110 + <tr>
111 + <td style="padding: 2px 0;">
112 + <span style="display:inline-block;padding:2px 7px;border-radius:4px;font-size:11px;background:<?php echo esc_attr($pillBg); ?>;color:<?php echo esc_attr($pillColor); ?>;">
113 + <?php
114 + /* translators: %1$s: tax label e.g. "VAT", %2$s: rate percentage e.g. "20" or "7.5" */
115 + echo esc_html(sprintf(__('%1$s (%2$s%%)', 'fluent-cart'), $rate['label'], rtrim(rtrim(number_format((float) $rate['rate_percent'], 3, '.', ''), '0'), '.')));
116 + ?>
117 + </span>
118 + </td>
119 + <td style="text-align:right;padding: 2px 0;">
120 + <span style="font-size:11px;font-weight:500;color:<?php echo esc_attr($pillColor); ?>;<?php echo esc_attr($reversedAmountStyle); ?>">
121 + <?php if ($rate['inclusive']): ?>
122 + <?php /* translators: %1$s: formatted tax amount e.g. "$3.92" */ ?>
123 + <?php echo esc_html(sprintf(__('incl. %1$s', 'fluent-cart'), \FluentCart\App\Helpers\Helper::toDecimal($rate['tax_amount']))); ?>
124 + <?php else: ?>
125 + + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($rate['tax_amount'])); ?>
126 + <?php endif; ?>
127 + </span>
128 + </td>
129 + </tr>
130 + <?php endforeach; ?>
131 + </table>
132 + </td>
133 + </tr>
134 + <?php elseif ($fctEmailDisplayMode !== 'simplified' && !empty($item['tax_amount'])): ?>
135 + <?php
136 + $itemIsInclusive = TaxSummaryHelper::isPrimaryTaxInclusive($order);
137 + $reversedAmountStyle = ($isReversed && (!$itemIsInclusive || $rcMode === 'dynamic')) ? 'text-decoration:line-through;opacity:0.6;' : '';
138 + $pillBg = $itemIsInclusive ? '#EAF3DE' : '#FAEEDA';
139 + $pillColor = $itemIsInclusive ? '#3B6D11' : '#854F0B';
140 + $pillLabel = $itemIsInclusive ? esc_html__('Tax (incl.)', 'fluent-cart') : esc_html__('Tax (excl.)', 'fluent-cart');
141 + ?>
142 + <tr>
143 + <td colspan="3" style="padding: 0 16px 8px;">
144 + <table width="100%" style="border-spacing:0;border-collapse:collapse;">
145 + <tr>
146 + <td style="padding: 2px 0;">
147 + <span style="display:inline-block;padding:2px 7px;border-radius:4px;font-size:11px;background:<?php echo esc_attr($pillBg); ?>;color:<?php echo esc_attr($pillColor); ?>;">
148 + <?php echo $pillLabel; ?>
149 + </span>
150 + </td>
151 + <td style="text-align:right;padding: 2px 0;">
152 + <span style="font-size:11px;font-weight:500;color:<?php echo esc_attr($pillColor); ?>;<?php echo esc_attr($reversedAmountStyle); ?>">
153 + <?php if ($itemIsInclusive): ?>
154 + <?php /* translators: %1$s: formatted tax amount e.g. "$3.92" */ ?>
155 + <?php echo esc_html(sprintf(__('incl. %1$s', 'fluent-cart'), \FluentCart\App\Helpers\Helper::toDecimal((int) $item['tax_amount']))); ?>
156 + <?php else: ?>
157 + + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal((int) $item['tax_amount'])); ?>
158 + <?php endif; ?>
159 + </span>
160 + </td>
161 + </tr>
162 + </table>
163 + </td>
164 + </tr>
165 + <?php endif; ?>
166 +
167 + <?php if (!empty($item['setup_info'])): ?>
168 + <tr>
169 + <td colspan="3" style="padding: 0 16px 2px;">
170 + <p style="font-size:12px;color:rgb(75,85,99);line-height:20px;margin: 3px 0 0 0;">
171 + <?php echo wp_kses_post($item['setup_info']); ?>
172 + </p>
173 + </td>
174 + </tr>
175 + <?php endif; ?>
176 +
177 + <?php if (($item['payment_type'] ?? '') === 'subscription'): ?>
178 + <?php
179 + $sfSibling = null;
180 + foreach ($allOrderItems as $sfCandidate) {
181 + if (($sfCandidate['payment_type'] ?? '') !== 'signup_fee') {
182 + continue;
183 + }
184 + $parentId = isset($sfCandidate['line_meta']['parent_item_id']) ? (int) $sfCandidate['line_meta']['parent_item_id'] : 0;
185 + if ($parentId && $parentId === (int) $item['id']) {
186 + $sfSibling = $sfCandidate;
187 + break;
188 + }
189 + if (!$parentId && $sfCandidate['object_id'] === $item['object_id']) {
190 + $sfSibling = $sfCandidate;
191 + break;
192 + }
193 + }
194 + $sfRates = $sfSibling ? TaxSummaryHelper::getItemTaxRates($sfSibling) : [];
195 + ?>
196 + <?php if ($fctEmailDisplayMode !== 'simplified' && !empty($sfRates)): ?>
197 + <tr>
198 + <td colspan="3" style="padding: 0 16px 8px;">
199 + <table width="100%" style="border-spacing:0;border-collapse:collapse;">
200 + <?php foreach ($sfRates as $sfRate):
201 + $sfBg = $sfRate['inclusive'] ? '#EAF3DE' : '#FAEEDA';
202 + $sfColor = $sfRate['inclusive'] ? '#3B6D11' : '#854F0B';
203 + $sfRateIsInclusive = !empty($sfRate['inclusive']);
204 + $reversedAmountStyle = ($isReversed && (!$sfRateIsInclusive || $rcMode === 'dynamic')) ? 'text-decoration:line-through;opacity:0.6;' : '';
205 + ?>
206 + <tr>
207 + <td style="padding: 2px 0;">
208 + <span style="display:inline-block;padding:2px 7px;border-radius:4px;font-size:11px;background:<?php echo esc_attr($sfBg); ?>;color:<?php echo esc_attr($sfColor); ?>;">
209 + <?php
210 + /* translators: %1$s: tax label e.g. "VAT", %2$s: rate percentage e.g. "20" or "7.5" */
211 + echo esc_html(sprintf(__('Setup Fee — %1$s (%2$s%%)', 'fluent-cart'), $sfRate['label'], rtrim(rtrim(number_format((float) $sfRate['rate_percent'], 3, '.', ''), '0'), '.')));
212 + ?>
213 + </span>
214 + </td>
215 + <td style="text-align:right;padding: 2px 0;">
216 + <span style="font-size:11px;font-weight:500;color:<?php echo esc_attr($sfColor); ?>;<?php echo esc_attr($reversedAmountStyle); ?>">
217 + <?php if ($sfRate['inclusive']): ?>
218 + <?php /* translators: %1$s: formatted tax amount e.g. "$3.92" */ ?>
219 + <?php echo esc_html(sprintf(__('incl. %1$s', 'fluent-cart'), \FluentCart\App\Helpers\Helper::toDecimal($sfRate['tax_amount']))); ?>
220 + <?php else: ?>
221 + + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($sfRate['tax_amount'])); ?>
222 + <?php endif; ?>
223 + </span>
224 + </td>
225 + </tr>
226 + <?php endforeach; ?>
227 + </table>
228 + </td>
229 + </tr>
230 + <?php else: ?>
231 + <?php
232 + if ($sfSibling) {
233 + $sfTax = (int) ($sfSibling['tax_amount'] ?? 0);
234 + } else {
235 + $sfOtherInfo = is_array($item['other_info'] ?? null) ? $item['other_info'] : [];
236 + $sfTax = (int) Arr::get($sfOtherInfo, 'signup_fee_tax', 0);
237 + }
238 + ?>
239 + <?php if ($fctEmailDisplayMode !== 'simplified' && $sfTax > 0): ?>
240 + <?php
241 + $sfIsInclusive = TaxSummaryHelper::isPrimaryTaxInclusive($order);
242 + $reversedAmountStyle = ($isReversed && (!$sfIsInclusive || $rcMode === 'dynamic')) ? 'text-decoration:line-through;opacity:0.6;' : '';
243 + $sfFallbackBg = $sfIsInclusive ? '#EAF3DE' : '#FAEEDA';
244 + $sfFallbackColor = $sfIsInclusive ? '#3B6D11' : '#854F0B';
245 + ?>
246 + <tr>
247 + <td colspan="3" style="padding: 0 16px 8px;">
248 + <table width="100%" style="border-spacing:0;border-collapse:collapse;">
249 + <tr>
250 + <td style="padding: 2px 0;">
251 + <span style="display:inline-block;padding:2px 7px;border-radius:4px;font-size:11px;background:<?php echo esc_attr($sfFallbackBg); ?>;color:<?php echo esc_attr($sfFallbackColor); ?>;">
252 + <?php echo esc_html__('Setup Fee Tax', 'fluent-cart'); ?>
253 + </span>
254 + </td>
255 + <td style="text-align:right;padding: 2px 0;">
256 + <span style="font-size:11px;font-weight:500;color:<?php echo esc_attr($sfFallbackColor); ?>;<?php echo esc_attr($reversedAmountStyle); ?>">
257 + <?php if ($sfIsInclusive): ?>
258 + <?php /* translators: %1$s: formatted tax amount e.g. "$3.92" */ ?>
259 + <?php echo esc_html(sprintf(__('incl. %1$s', 'fluent-cart'), \FluentCart\App\Helpers\Helper::toDecimal($sfTax))); ?>
260 + <?php else: ?>
261 + + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($sfTax)); ?>
262 + <?php endif; ?>
263 + </span>
264 + </td>
265 + </tr>
266 + </table>
267 + </td>
268 + </tr>
269 + <?php endif; ?>
270 + <?php endif; ?>
271 + <?php endif; ?>
89 272 <?php endforeach; ?>
90 273 </tbody>
91 274 </table>
92 -<table style="border-spacing:0;padding: 0; width: 100%;border: none;">
275 +<table style="border-spacing:0;padding: 0; width: 100%;border: none;margin-top:8px;">
93 276 <tr>
277 + <td colspan="2" style="border-top:1px solid #e5e7eb;padding-top:12px;font-size:0;line-height:0;">&nbsp;</td>
278 + </tr>
279 + <tr>
94 280 <td style="width: 50%;"></td>
95 281 <td style="width: 100%;">
96 - <table role="presentation"
97 - style="background-color:rgb(249,250,251);padding:16px;border-radius:8px;margin: 0; width: 100%;border: none;">
282 + <table role="presentation" width="400"
283 + style="margin: 0 0 0 auto; width: 400px; max-width: 100%; border: none;">
98 284 <tbody>
285 + <!-- Zone A: plain subtotal / shipping / fees / discount -->
99 286 <?php if ($order->subtotal != $order->total_amount): ?>
100 287 <tr style="width:100%">
101 288 <td style="width:70%">
102 289 <p style="font-size:14px;color:rgb(55,65,81);line-height:24px;margin: 0;">
@@ -110,80 +297,426 @@
110 297 </td>
111 298 </tr>
112 299 <?php endif; ?>
113 300
114 - <?php if ($order->shipping_total > 0): ?>
301 + <?php
302 + // Compute summary early so rcShippingAdjustment is available for the shipping row.
303 + $emailTaxSummaryEarly = ($order instanceof \FluentCart\App\Models\Order)
304 + ? TaxSummaryHelper::computeTaxSummary($order)
305 + : ['shouldRender' => false, 'rcShippingAdjustment' => 0, 'rcTotalAdjustment' => 0];
306 + $emailRcShippingAdj = (int) \FluentCart\Framework\Support\Arr::get($emailTaxSummaryEarly, 'rcShippingAdjustment', 0);
307 + ?>
308 + <?php if ($order->shipping_total > 0):
309 + $emailDisplayShipping = max(0, (int) $order->shipping_total - $emailRcShippingAdj);
310 + $emailShippingMethodTitle = (string) \FluentCart\Framework\Support\Arr::get($order->config, 'shipping_method_title', '');
311 + ?>
115 312 <tr style="width:100%">
116 313 <td style="width:70%">
117 314 <p style="font-size:14px;color:rgb(55,65,81);line-height:24px;margin: 0;">
118 315 <?php echo esc_html__('Shipping', 'fluent-cart'); ?>
119 316 </p>
317 + <?php if ($emailShippingMethodTitle): ?>
318 + <p style="font-size:12px;color:rgb(107,114,128);line-height:18px;margin:0;">
319 + <?php echo esc_html($emailShippingMethodTitle); ?>
320 + </p>
321 + <?php endif; ?>
120 322 </td>
121 323 <td style="width:30%;text-align:right">
122 324 <p style="font-size:14px;color:rgb(55,65,81);margin:0;line-height:24px;">
123 - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->shipping_total)); ?>
325 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailDisplayShipping)); ?>
124 326 </p>
125 327 </td>
126 328 </tr>
127 329 <?php endif; ?>
128 - <?php if ($order->shipping_tax > 0): ?>
330 + <?php foreach ($feeItems as $feeItem): ?>
129 331 <tr style="width:100%">
130 332 <td style="width:70%">
131 333 <p style="font-size:14px;color:rgb(55,65,81);line-height:24px;margin: 0;">
132 - <?php echo esc_html__('Shipping Tax', 'fluent-cart'); ?>
133 - <?php echo esc_html($order->tax_behavior == 2 ? __('(Included)', 'fluent-cart') : __('(Excluded)', 'fluent-cart')); ?>
334 + <?php echo esc_html($feeItem['title']); ?>
134 335 </p>
135 336 </td>
136 337 <td style="width:30%;text-align:right">
137 338 <p style="font-size:14px;color:rgb(55,65,81);margin:0;line-height:24px;">
138 - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->shipping_tax)); ?>
339 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($feeItem['subtotal'])); ?>
139 340 </p>
140 341 </td>
141 342 </tr>
142 - <?php endif; ?>
143 - <?php foreach ($feeItems as $feeItem): ?>
343 + <?php endforeach; ?>
344 + <?php
345 + $prorateCredit = (int) \FluentCart\Framework\Support\Arr::get($order->config, 'prorate_credit', 0);
346 + $upgradeDiscount = $order->manual_discount_total - $prorateCredit;
347 + // When the prorate credit IS the whole discount, label the row directly
348 + // instead of showing "Discount" with a single redundant breakdown row.
349 + $onlyProrateCredit = $prorateCredit > 0 && $upgradeDiscount <= 0 && $order->coupon_discount_total <= 0;
350 + ?>
351 + <?php if ($order->manual_discount_total + $order->coupon_discount_total > 0): ?>
144 352 <tr style="width:100%">
145 353 <td style="width:70%">
146 354 <p style="font-size:14px;color:rgb(55,65,81);line-height:24px;margin: 0;">
147 - <?php echo esc_html($feeItem['title']); ?>
355 + <?php echo $onlyProrateCredit ? esc_html__('Prorate Credit', 'fluent-cart') : esc_html__('Discount', 'fluent-cart'); ?>
148 356 </p>
149 357 </td>
150 358 <td style="width:30%;text-align:right">
151 - <p style="font-size:14px;color:rgb(55,65,81);margin:0;line-height:24px;">
152 - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($feeItem['subtotal'])); ?>
359 + <p style="font-size:14px;color:rgb(55,65,81);line-height:24px;margin: 0;">
360 + - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->manual_discount_total + $order->coupon_discount_total)); ?>
153 361 </p>
154 362 </td>
155 363 </tr>
156 - <?php endforeach; ?>
157 - <?php if ($order->manual_discount_total + $order->coupon_discount_total > 0): ?>
364 + <?php if ($prorateCredit > 0 && $upgradeDiscount > 0): ?>
365 + <tr style="width:100%">
366 + <td style="width:70%;padding-left:12px;">
367 + <p style="font-size:12px;color:rgb(107,114,128);line-height:20px;margin: 0;">
368 + <?php echo esc_html__('Upgrade Discount', 'fluent-cart'); ?>
369 + </p>
370 + </td>
371 + <td style="width:30%;text-align:right">
372 + <p style="font-size:12px;color:rgb(107,114,128);margin:0;line-height:20px;">
373 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($upgradeDiscount)); ?>
374 + </p>
375 + </td>
376 + </tr>
377 + <?php endif; ?>
378 + <?php if ($prorateCredit > 0 && !$onlyProrateCredit): ?>
379 + <tr style="width:100%">
380 + <td style="width:70%;padding-left:12px;">
381 + <p style="font-size:12px;color:rgb(107,114,128);line-height:20px;margin: 0;">
382 + <?php echo esc_html__('Prorate Credit', 'fluent-cart'); ?>
383 + </p>
384 + </td>
385 + <td style="width:30%;text-align:right">
386 + <p style="font-size:12px;color:rgb(107,114,128);margin:0;line-height:20px;">
387 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($prorateCredit)); ?>
388 + </p>
389 + </td>
390 + </tr>
391 + <?php endif; ?>
392 + <?php endif; ?>
393 +
394 + <?php
395 + $emailTaxSummary = isset($emailTaxSummaryEarly) ? $emailTaxSummaryEarly : (($order instanceof \FluentCart\App\Models\Order)
396 + ? TaxSummaryHelper::computeTaxSummary($order)
397 + : ['shouldRender' => false]);
398 + if ($emailTaxSummary['shouldRender']):
399 + $emailFoldedRateLines = Arr::get($emailTaxSummary, 'foldedRateLines', []);
400 + $emailIncludedInPrices = (int) Arr::get($emailTaxSummary, 'includedInPrices', 0);
401 + $emailPayableTax = (int) Arr::get($emailTaxSummary, 'payableTax', 0);
402 + $emailTotalOrderTax = (int) Arr::get($emailTaxSummary, 'totalOrderTax', 0);
403 + ?>
404 + </tbody>
405 + </table><!-- /Zone A -->
406 + <!-- Zone B: tax breakdown inside its own grey box -->
407 + <table role="presentation" align="right" width="400"
408 + style="border-spacing:0;border-collapse:collapse;margin:12px 0 0 auto;width:400px;max-width:100%;border:none;">
409 + <tbody>
410 + <tr>
411 + <td style="background-color:rgb(249,250,251);padding:16px;border-radius:8px;">
412 + <table role="presentation" width="100%"
413 + style="width:100%;border-spacing:0;border-collapse:collapse;border:none;">
414 + <tbody>
415 + <?php if (($emailTaxSummary['displayMode'] ?? '') === 'simplified' && !empty($emailTaxSummary['simpleLine'])): ?>
158 416 <tr style="width:100%">
159 417 <td style="width:70%">
160 - <p style="font-size:14px;color:rgb(55,65,81);line-height:24px;margin: 0;">
161 - <?php echo esc_html__('Discount', 'fluent-cart'); ?>
418 + <p style="font-size:14px; font-weight:700; color:#1e293b; line-height:24px; margin:0;">
419 + <?php echo esc_html($emailTaxSummary['simpleLine']['label']); ?>
162 420 </p>
163 421 </td>
164 - <td style="width:30%;text-align:right">
165 - <p style="font-size:14px;color:rgb(55,65,81);line-height:24px;margin: 0;">
166 - - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->manual_discount_total + $order->coupon_discount_total)); ?>
422 + <td style="width:30%; text-align:right">
423 + <p style="font-size:14px; font-weight:700; color:#1e293b; margin:0; line-height:24px;">
424 + <?php echo esc_html($emailTaxSummary['simpleLine']['value']); ?>
167 425 </p>
168 426 </td>
169 427 </tr>
170 428 <?php endif; ?>
171 - <?php if ($order->tax_total > 0): ?>
429 + <?php if (($emailTaxSummary['displayMode'] ?? '') !== 'simplified'): ?>
430 + <tr style="width:100%">
431 + <td colspan="2" style="padding:0 0 4px;">
432 + <p style="font-size:10px; font-weight:600; text-transform:uppercase;
433 + letter-spacing:0.06em; color:#94a3b8; margin:0;">
434 + <?php if (!empty($emailFoldedRateLines)): ?>
435 + <?php echo esc_html__('Tax breakdown by rate', 'fluent-cart'); ?>
436 + <?php else: ?>
437 + <?php echo esc_html__('TAX', 'fluent-cart'); ?>
438 + <?php endif; ?>
439 + </p>
440 + </td>
441 + </tr>
442 + <?php
443 + $rcReversedTotal = (int) Arr::get($emailTaxSummary, 'reversedTaxTotal', 0);
444 + $rcReversedShipping = (int) Arr::get($emailTaxSummary, 'reversedShippingTax', 0);
445 + $rcReversedValue = $rcReversedTotal > 0
446 + ? \FluentCart\App\Helpers\Helper::toDecimal($rcReversedTotal)
447 + : __('Charge reversed', 'fluent-cart');
448 + ?>
449 + <?php if (!empty($emailFoldedRateLines)): ?>
172 450 <tr style="width:100%">
451 + <td colspan="2" style="padding:0 0 4px;">
452 + <table style="width:100%;border-collapse:collapse;border-spacing:0;table-layout:fixed;">
453 + <tbody>
454 + <tr>
455 + <td style="width:58%;font-size:11px;text-transform:uppercase;color:rgb(107,114,128);font-weight:600;padding:2px 12px 2px 0;border:none;white-space:nowrap;">
456 + <?php echo esc_html__('Rate', 'fluent-cart'); ?>
457 + </td>
458 + <td style="width:24%;font-size:11px;text-transform:uppercase;color:rgb(107,114,128);font-weight:600;padding:2px 12px 2px 0;text-align:right;border:none;white-space:nowrap;">
459 + <?php echo esc_html__('Taxable base', 'fluent-cart'); ?>
460 + </td>
461 + <td style="width:18%;font-size:11px;text-transform:uppercase;color:rgb(107,114,128);font-weight:600;padding:2px 0 2px 0;text-align:right;border:none;white-space:nowrap;">
462 + <?php echo esc_html__('Tax', 'fluent-cart'); ?>
463 + </td>
464 + </tr>
465 + <?php foreach ($emailFoldedRateLines as $emailFoldedLine):
466 + $emailFoldedColor = !empty($emailFoldedLine['inclusive']) ? '#94a3b8' : '#1e293b';
467 + ?>
468 + <tr>
469 + <td style="width:58%;font-size:14px;line-height:20px;padding:3px 12px 3px 0;border:none;color:<?php echo esc_attr($emailFoldedColor); ?>;white-space:normal;word-break:break-word;overflow-wrap:break-word;vertical-align:top;">
470 + <?php echo esc_html($emailFoldedLine['label']); ?>
471 + </td>
472 + <td style="width:24%;font-size:13px;line-height:20px;padding:3px 12px 3px 0;text-align:right;border:none;color:#94a3b8;white-space:nowrap;vertical-align:top;">
473 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailFoldedLine['base'])); ?>
474 + </td>
475 + <td style="width:18%;font-size:13px;line-height:20px;padding:3px 0 3px 0;text-align:right;border:none;color:<?php echo esc_attr($emailFoldedColor); ?>;white-space:nowrap;vertical-align:top;">
476 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailFoldedLine['tax'])); ?>
477 + </td>
478 + </tr>
479 + <?php endforeach; ?>
480 + </tbody>
481 + </table>
482 + </td>
483 + </tr>
484 + <?php if ($emailTaxSummary['isReverseCharge']): ?>
485 + <tr style="width:100%">
173 486 <td style="width:70%">
174 - <p style="font-size:14px;color:rgb(55,65,81);line-height:24px;margin: 0;">
175 - <?php echo esc_html__('Tax', 'fluent-cart'); ?>
176 - <?php echo esc_html($order->tax_behavior == 2 ? __('(Included)', 'fluent-cart') : __('(Excluded)', 'fluent-cart')); ?>
487 + <p style="font-size:14px; font-weight:700; color:#1e293b; line-height:24px; margin:0; border-top:1px solid #e2e8f0; padding-top:4px;">
488 + <?php echo esc_html__('VAT reversed', 'fluent-cart'); ?>
177 489 </p>
178 490 </td>
179 - <td style="width:30%;text-align:right">
180 - <p style="font-size:14px;color:rgb(55,65,81);margin:0;line-height:24px;">
181 - <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->tax_total)); ?>
491 + <td style="width:30%; text-align:right">
492 + <p style="font-size:14px; font-weight:700; color:#1e293b; margin:0; line-height:24px; border-top:1px solid #e2e8f0; padding-top:4px;">
493 + <?php echo esc_html($rcReversedValue); ?>
182 494 </p>
183 495 </td>
184 496 </tr>
497 + <?php else: ?>
498 + <tr style="width:100%">
499 + <td style="width:70%">
500 + <p style="font-size:14px; font-weight:700; color:#1e293b; line-height:24px; margin:0; border-top:1px solid #e2e8f0; padding-top:4px;">
501 + <?php echo esc_html__('Total tax', 'fluent-cart'); ?>
502 + </p>
503 + </td>
504 + <td style="width:30%; text-align:right">
505 + <p style="font-size:14px; font-weight:700; color:#1e293b; margin:0; line-height:24px; border-top:1px solid #e2e8f0; padding-top:4px;">
506 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailTotalOrderTax)); ?>
507 + </p>
508 + </td>
509 + </tr>
510 + <?php if ($emailIncludedInPrices > 0): ?>
511 + <tr style="width:100%">
512 + <td style="width:70%">
513 + <p style="font-size:13px; color:#94a3b8; line-height:22px; margin:0;">
514 + <?php echo esc_html__('of which included in prices', 'fluent-cart'); ?>
515 + </p>
516 + </td>
517 + <td style="width:30%; text-align:right">
518 + <p style="font-size:13px; color:#94a3b8; margin:0; line-height:22px;">
519 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailIncludedInPrices)); ?>
520 + </p>
521 + </td>
522 + </tr>
523 + <?php endif; ?>
524 + <?php if ($emailPayableTax > 0 && $emailIncludedInPrices > 0): ?>
525 + <tr style="width:100%">
526 + <td style="width:70%;border-top:1px solid #e2e8f0;padding-top:6px;margin-top:6px;">
527 + <p style="font-size:14px; font-weight:700; color:#1e293b; line-height:24px; margin:0;">
528 + <?php echo esc_html__('Payable now (added)', 'fluent-cart'); ?>
529 + </p>
530 + </td>
531 + <td style="width:30%; text-align:right;border-top:1px solid #e2e8f0;padding-top:6px;margin-top:6px;">
532 + <p style="font-size:14px; font-weight:700; color:#1e293b; margin:0; line-height:24px;">
533 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailPayableTax)); ?>
534 + </p>
535 + </td>
536 + </tr>
537 + <?php endif; ?>
538 + <?php endif; ?>
539 + <?php elseif ($emailTaxSummary['isReverseCharge']): ?>
540 + <?php if ($emailTaxSummary['showRcShippingRow'] && $rcReversedShipping > 0): ?>
541 + <tr style="width:100%">
542 + <td style="width:70%">
543 + <p style="font-size:14px; color:#94a3b8; line-height:24px; margin:0;">
544 + <?php echo esc_html__('Added on shipping', 'fluent-cart'); ?>
545 + </p>
546 + </td>
547 + <td style="width:30%; text-align:right">
548 + <p style="font-size:14px; color:#94a3b8; margin:0; line-height:24px;">
549 + <span style="text-decoration:line-through;opacity:0.6;"><?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($rcReversedShipping)); ?></span>
550 + </p>
551 + </td>
552 + </tr>
553 + <?php endif; ?>
554 + <tr style="width:100%">
555 + <td style="width:70%">
556 + <p style="font-size:14px; font-weight:700; color:#1e293b; line-height:24px; margin:0;">
557 + <?php echo esc_html__('Tax reversed', 'fluent-cart'); ?>
558 + </p>
559 + </td>
560 + <td style="width:30%; text-align:right">
561 + <p style="font-size:14px; font-weight:700; color:#1e293b; margin:0; line-height:24px;">
562 + <?php echo esc_html($rcReversedValue); ?>
563 + </p>
564 + </td>
565 + </tr>
566 + <?php else: ?>
567 + <?php
568 + $emailFeeRowsList = Arr::get($emailTaxSummary, 'feeTaxLineRows', []);
569 + $emailTaxRateLines = Arr::get($emailTaxSummary, 'taxRateLines', []);
570 + $emailShippingLines = Arr::get($emailTaxSummary, 'shippingTaxLines', []);
571 + $productTaxRowCount = !empty($emailTaxRateLines)
572 + ? count($emailTaxRateLines)
573 + : (int) ($emailTaxSummary['inclusiveTax'] > 0) + (int) ($emailTaxSummary['exclusiveTax'] > 0);
574 + $rowCount = $productTaxRowCount + count($emailFeeRowsList) + (int) ($emailTaxSummary['shippingTax'] > 0);
575 + $shouldShowBreakdown = !empty($emailTaxRateLines)
576 + || !empty($emailShippingLines)
577 + || $rowCount >= 2
578 + || ($rowCount === 1 && !($emailTaxSummary['payableTax'] > 0 || $emailTaxSummary['inclusiveTax'] > 0 || (int) Arr::get($emailTaxSummary, 'inclusiveFeeTax', 0) > 0));
579 + ?>
580 + <?php if (!empty($emailTaxRateLines) && $shouldShowBreakdown): ?>
581 + <?php foreach ($emailTaxRateLines as $emailTaxRateLine):
582 + $emailTaxRateColor = !empty($emailTaxRateLine['inclusive']) ? '#94a3b8' : '#1e293b';
583 + $emailTaxRateWeight = !empty($emailTaxRateLine['inclusive']) ? 'normal' : '600'; ?>
584 + <tr style="width:100%">
585 + <td style="width:70%">
586 + <p style="font-size:14px; font-weight:<?php echo esc_attr($emailTaxRateWeight); ?>; color:<?php echo esc_attr($emailTaxRateColor); ?>; line-height:24px; margin:0;">
587 + <?php echo esc_html($emailTaxRateLine['label']); ?>
588 + </p>
589 + </td>
590 + <td style="width:30%; text-align:right">
591 + <p style="font-size:14px; font-weight:<?php echo esc_attr($emailTaxRateWeight); ?>; color:<?php echo esc_attr($emailTaxRateColor); ?>; margin:0; line-height:24px;">
592 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailTaxRateLine['order_tax'])); ?>
593 + </p>
594 + </td>
595 + </tr>
596 + <?php endforeach; ?>
597 + <?php endif; ?>
598 + <?php if (empty($emailTaxRateLines) && $emailTaxSummary['inclusiveTax'] > 0 && $shouldShowBreakdown): ?>
599 + <tr style="width:100%">
600 + <td style="width:70%">
601 + <p style="font-size:14px; color:#94a3b8; line-height:24px; margin:0;">
602 + <?php echo esc_html__('Included in item prices', 'fluent-cart'); ?>
603 + </p>
604 + </td>
605 + <td style="width:30%; text-align:right">
606 + <p style="font-size:14px; color:#94a3b8; margin:0; line-height:24px;">
607 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailTaxSummary['inclusiveTax'])); ?>
608 + </p>
609 + </td>
610 + </tr>
611 + <?php endif; ?>
612 + <?php if (empty($emailTaxRateLines) && $emailTaxSummary['exclusiveTax'] > 0 && $shouldShowBreakdown): ?>
613 + <tr style="width:100%">
614 + <td style="width:70%">
615 + <p style="font-size:14px; font-weight:600; color:#1e293b; line-height:24px; margin:0;">
616 + <?php echo esc_html__('Added on products', 'fluent-cart'); ?>
617 + </p>
618 + </td>
619 + <td style="width:30%; text-align:right">
620 + <p style="font-size:14px; font-weight:600; color:#1e293b; margin:0; line-height:24px;">
621 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailTaxSummary['exclusiveTax'])); ?>
622 + </p>
623 + </td>
624 + </tr>
625 + <?php endif; ?>
626 + <?php if ($shouldShowBreakdown) : ?>
627 + <?php foreach ($emailFeeRowsList as $emailFeeRow):
628 + $emailFeeColor = $emailFeeRow['inclusive'] ? '#94a3b8' : '#1e293b';
629 + $emailFeeWeight = $emailFeeRow['inclusive'] ? 'normal' : '600'; ?>
630 + <tr style="width:100%">
631 + <td style="width:70%">
632 + <p style="font-size:14px; font-weight:<?php echo esc_attr($emailFeeWeight); ?>; color:<?php echo esc_attr($emailFeeColor); ?>; line-height:24px; margin:0;">
633 + <?php echo esc_html($emailFeeRow['display_label']); ?>
634 + </p>
635 + </td>
636 + <td style="width:30%; text-align:right">
637 + <p style="font-size:14px; font-weight:<?php echo esc_attr($emailFeeWeight); ?>; color:<?php echo esc_attr($emailFeeColor); ?>; margin:0; line-height:24px;">
638 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailFeeRow['tax_amount'])); ?>
639 + </p>
640 + </td>
641 + </tr>
642 + <?php endforeach; ?>
643 + <?php endif; ?>
644 + <?php if ($emailTaxSummary['shippingTax'] > 0 && $shouldShowBreakdown):
645 + $isShippingInclusive = (bool) Arr::get($emailTaxSummary, 'isShippingInclusive', false);
646 + $emailShippingColor = $isShippingInclusive ? '#94a3b8' : '#1e293b';
647 + $emailShippingWeight = $isShippingInclusive ? 'normal' : '600';
648 + if (!empty($emailShippingLines)):
649 + foreach ($emailShippingLines as $shLine): ?>
650 + <tr style="width:100%">
651 + <td style="width:70%">
652 + <p style="font-size:14px; font-weight:<?php echo esc_attr($emailShippingWeight); ?>; color:<?php echo esc_attr($emailShippingColor); ?>; line-height:24px; margin:0;">
653 + <?php echo esc_html($shLine['label']); ?>
654 + </p>
655 + </td>
656 + <td style="width:30%; text-align:right">
657 + <p style="font-size:14px; font-weight:<?php echo esc_attr($emailShippingWeight); ?>; color:<?php echo esc_attr($emailShippingColor); ?>; margin:0; line-height:24px;">
658 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($shLine['shipping_tax'])); ?>
659 + </p>
660 + </td>
661 + </tr>
662 + <?php endforeach;
663 + else: ?>
664 + <tr style="width:100%">
665 + <td style="width:70%">
666 + <p style="font-size:14px; font-weight:<?php echo esc_attr($emailShippingWeight); ?>; color:<?php echo esc_attr($emailShippingColor); ?>; line-height:24px; margin:0;">
667 + <?php echo esc_html($isShippingInclusive ? __('Included in shipping prices', 'fluent-cart') : __('Added on shipping', 'fluent-cart')); ?>
668 + </p>
669 + </td>
670 + <td style="width:30%; text-align:right">
671 + <p style="font-size:14px; font-weight:<?php echo esc_attr($emailShippingWeight); ?>; color:<?php echo esc_attr($emailShippingColor); ?>; margin:0; line-height:24px;">
672 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailTaxSummary['shippingTax'])); ?>
673 + </p>
674 + </td>
675 + </tr>
676 + <?php endif; ?>
677 + <?php endif; ?>
678 + <?php if ($emailTaxSummary['payableTax'] > 0): ?>
679 + <tr style="width:100%">
680 + <td style="width:70%">
681 + <p style="font-size:14px; font-weight:700; color:#1e293b; line-height:24px; margin:0; border-top:1px solid #e2e8f0; padding-top:4px;">
682 + <?php echo esc_html__('Total payable tax', 'fluent-cart'); ?>
683 + </p>
684 + </td>
685 + <td style="width:30%; text-align:right">
686 + <p style="font-size:14px; font-weight:700; color:#1e293b; margin:0; line-height:24px; border-top:1px solid #e2e8f0; padding-top:4px;">
687 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailTaxSummary['payableTax'])); ?>
688 + </p>
689 + </td>
690 + </tr>
691 + <?php endif; ?>
692 + <?php if ($emailTaxSummary['inclusiveTax'] > 0 || $emailTaxSummary['inclusiveFeeTax'] > 0): ?>
693 + <tr style="width:100%">
694 + <td style="width:70%">
695 + <p style="font-size:14px; font-weight:normal; color:#94a3b8; line-height:24px; margin:0;">
696 + <?php echo esc_html__('Total tax in this order', 'fluent-cart'); ?>
697 + </p>
698 + </td>
699 + <td style="width:30%; text-align:right">
700 + <p style="font-size:14px; font-weight:normal; color:#94a3b8; margin:0; line-height:24px;">
701 + <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($emailTaxSummary['totalOrderTax'])); ?>
702 + </p>
703 + </td>
704 + </tr>
705 + <?php endif; ?>
185 706 <?php endif; ?>
707 + <?php endif; ?>
708 + </tbody>
709 + </table>
710 + </td>
711 + </tr>
712 + </tbody>
713 + </table><!-- /Zone B: grey tax box -->
714 + <table role="presentation" width="400"
715 + style="margin:12px 0 0 auto; width: 400px; max-width: 100%; border: none;">
716 + <tbody>
717 + <!-- Zone C: plain refund / total / payment -->
718 + <?php endif; ?>
186 719
187 720 <?php if ($order->total_refund > 0 && $isRefund): ?>
188 721 <tr style="width:100%">
189 722 <td style="width:70%">
@@ -198,8 +731,12 @@
198 731 </td>
199 732 </tr>
200 733 <?php endif; ?>
201 734
735 + <?php
736 + $emailDisplayTotal = max(0, (int) $order->total_amount - (int) $order->total_refund
737 + - (int) \FluentCart\Framework\Support\Arr::get($emailTaxSummaryEarly ?? [], 'rcTotalAdjustment', 0));
738 + ?>
202 739 <tr style="width:100%">
203 740 <td style="width:70%"><p
204 741 style="font-size:16px;font-weight:700;color:rgb(17,24,39);line-height:24px;margin: 0;">
205 742 <?php echo esc_html__('Total', 'fluent-cart'); ?>
@@ -206,9 +743,9 @@
206 743 </p>
207 744 </td>
208 745 <td style="width:30%;text-align:right">
209 746 <p style="font-size:14px;font-weight:700;color:rgb(17,24,39);line-height:24px;margin: 0;">
210 - <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice(($order->total_amount - $order->total_refund), null, false, true, true)); ?>
747 + <?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice($emailDisplayTotal, null, false, true, true)); ?>
211 748 </p>
212 749 </td>
213 750 </tr>
214 751
@@ -241,13 +778,11 @@
241 778 </tr>
242 779 </tbody>
243 780 </table>
244 781 <?php
245 - $orderTaxRates = $order->orderTaxRates->first();
246 - $taxtotal = $order->tax_total + $order->shipping_tax;
247 - if(Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.valid') && !$taxtotal): ?>
782 + if($order->isReverseChargeTaxOrder()): ?>
248 783 <div style="text-align: right; font-size: 14px; margin-top: 10px;">
249 - <?php echo '*' . esc_html__('Tax to be paid on reverse charge basis', 'fluent-cart'); ?>
784 + <?php echo '*' . esc_html(TaxModule::getReverseChargeNoticeText()); ?>
250 785 </div>
251 786
252 787 <?php endif ?>
253 788 </td>
@@ -252,7 +787,4 @@
252 787 <?php endif ?>
253 788 </td>
254 789 </tr>
255 790 </table>
256 -
257 -
258 -