| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Services\Renderer\Receipt; |
| 4 |
|
| 5 |
use FluentCart\App\Helpers\Helper; |
| 6 |
use FluentCart\Framework\Support\Arr; |
| 7 |
|
| 8 |
use FluentCart\Api\StoreSettings; |
| 9 |
use FluentCart\App\Helpers\AddressHelper; |
| 10 |
use FluentCart\App\Modules\Tax\TaxModule; |
| 11 |
use FluentCart\App\Services\DateTime\DateTime; |
| 12 |
|
| 13 |
class ReceiptRenderer |
| 14 |
{ |
| 15 |
protected $config = null; |
| 16 |
|
| 17 |
protected $is_first_time = false; |
| 18 |
|
| 19 |
protected $order_operation = null; |
| 20 |
|
| 21 |
protected $settings = null; |
| 22 |
|
| 23 |
protected $vat_tax_id = null; |
| 24 |
|
| 25 |
protected $orderTz; |
| 26 |
|
| 27 |
private $fctTaxSummaryCache = []; |
| 28 |
|
| 29 |
public function __construct($config = []) |
| 30 |
{ |
| 31 |
$this->config = $config; |
| 32 |
|
| 33 |
$this->is_first_time = Arr::get($this->config, 'is_first_time', false); |
| 34 |
$this->order_operation = Arr::get($this->config, 'order_operation', false); |
| 35 |
|
| 36 |
$this->settings = new StoreSettings(); |
| 37 |
|
| 38 |
$this->orderTz = Arr::get($this->config, 'user_tz', 'UTC'); |
| 39 |
} |
| 40 |
|
| 41 |
private function getMemoizedTaxSummary($order) |
| 42 |
{ |
| 43 |
if (!$order) { |
| 44 |
return TaxSummaryHelper::computeTaxSummary($order); |
| 45 |
} |
| 46 |
$id = (int) $order->id; |
| 47 |
if (!isset($this->fctTaxSummaryCache[$id])) { |
| 48 |
$this->fctTaxSummaryCache[$id] = TaxSummaryHelper::computeTaxSummary($order); |
| 49 |
} |
| 50 |
return $this->fctTaxSummaryCache[$id]; |
| 51 |
} |
| 52 |
|
| 53 |
public function wrapperStart() |
| 54 |
{ |
| 55 |
?> |
| 56 |
<div |
| 57 |
class="fct-receipt-page" |
| 58 |
style="background-color: #fff;max-width: 620px;margin-left: auto;margin-right: auto;border: 1px solid #e7eaee;padding: 10px;border-radius: 8px;"> |
| 59 |
<div |
| 60 |
class="fct-receipt-page-inner" |
| 61 |
style=" border-radius: 5px;" id="receipt"> |
| 62 |
<div class="fct-email-template-content email-template-content" |
| 63 |
style="font-family: Arial, Helvetica, sans-serif; margin: 0 auto; padding: 0px; width: 100%;"> |
| 64 |
<div class="fct-email-template-content-inner" style="font-size: 13px;line-height: 1.4;color: #333;padding: 20px;"> |
| 65 |
|
| 66 |
<?php |
| 67 |
} |
| 68 |
|
| 69 |
public function wrapperEnd() |
| 70 |
{ |
| 71 |
?> |
| 72 |
</div> |
| 73 |
</div> |
| 74 |
</div> |
| 75 |
</div> |
| 76 |
<?php |
| 77 |
} |
| 78 |
|
| 79 |
public function render($hideWrapper = false) |
| 80 |
{ |
| 81 |
|
| 82 |
$order = Arr::get($this->config, 'order', null); |
| 83 |
if (!$order) { |
| 84 |
return; |
| 85 |
} |
| 86 |
|
| 87 |
$this->vat_tax_id = $order->getCustomerTaxNumber(); |
| 88 |
|
| 89 |
$profilePage = $this->settings->getCustomerProfilePage(); |
| 90 |
$orderTaxRates = $order->getPrimaryOrderTaxRate(); |
| 91 |
|
| 92 |
?> |
| 93 |
|
| 94 |
<style> |
| 95 |
html { |
| 96 |
background-color: rgb(248, 249, 250); |
| 97 |
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; |
| 98 |
} |
| 99 |
|
| 100 |
body { |
| 101 |
background-color: rgb(248, 249, 250); |
| 102 |
padding-top: 40px; |
| 103 |
padding-bottom: 40px; |
| 104 |
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; |
| 105 |
} |
| 106 |
|
| 107 |
p { |
| 108 |
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; |
| 109 |
font-size: 14px; |
| 110 |
margin: 0px; |
| 111 |
margin-bottom: 8px; |
| 112 |
line-height: 24px; |
| 113 |
} |
| 114 |
|
| 115 |
.email_footer p { |
| 116 |
font-size: 12px; |
| 117 |
color: rgb(127, 140, 141); |
| 118 |
margin: 0px; |
| 119 |
line-height: 24px; |
| 120 |
margin-bottom: 8px; |
| 121 |
} |
| 122 |
|
| 123 |
hr { |
| 124 |
border-color: rgb(229, 231, 235); |
| 125 |
margin-bottom: 20px; |
| 126 |
width: 100%; |
| 127 |
border: none; |
| 128 |
border-top: 1px solid #eaeaea; |
| 129 |
} |
| 130 |
|
| 131 |
.space_bottom_30 { |
| 132 |
display: block; |
| 133 |
width: 100%; |
| 134 |
margin-bottom: 30px; |
| 135 |
} |
| 136 |
|
| 137 |
.fct-transaction-table tr:last-child td { |
| 138 |
border-bottom: none !important; |
| 139 |
padding-bottom: 0 !important; |
| 140 |
} |
| 141 |
</style> |
| 142 |
|
| 143 |
<?php if (!$hideWrapper) { |
| 144 |
$this->wrapperStart(); |
| 145 |
} ?> |
| 146 |
<?php $this->renderHeader(); ?> |
| 147 |
|
| 148 |
<?php $this->renderAddresses(); ?> |
| 149 |
|
| 150 |
<?php $this->renderOrderItems(); ?> |
| 151 |
|
| 152 |
<!-- tax note --> |
| 153 |
<?php $this->renderTaxNote(); ?> |
| 154 |
|
| 155 |
<?php $this->renderPaymentHistory(); ?> |
| 156 |
<?php if (!$hideWrapper) { |
| 157 |
$this->wrapperEnd(); |
| 158 |
} ?> |
| 159 |
|
| 160 |
|
| 161 |
<?php if ($this->is_first_time) { |
| 162 |
do_action('fluent_cart/order/receipt_viewed', [ |
| 163 |
'order' => $order, |
| 164 |
'order_operation' => $this->order_operation |
| 165 |
]); |
| 166 |
} ?> |
| 167 |
<?php |
| 168 |
} |
| 169 |
|
| 170 |
public function renderHeader() |
| 171 |
{ |
| 172 |
$order = Arr::get($this->config, 'order', null); |
| 173 |
?> |
| 174 |
<table |
| 175 |
class="fct-receipt-header" |
| 176 |
role="presentation" |
| 177 |
style="width: 100%;border-collapse: collapse;margin-bottom: 10px;border: none;"> |
| 178 |
<tbody style="width:100%"> |
| 179 |
<tr style="width:100%"> |
| 180 |
<td style="width:60%;border: none;"> |
| 181 |
<?php $this->renderHeaderLogo(); ?> |
| 182 |
|
| 183 |
<!-- show tax content --> |
| 184 |
<?php $this->renderStoreTaxInformation(); ?> |
| 185 |
</td> |
| 186 |
<td |
| 187 |
class="fct-receipt-header-date" |
| 188 |
style="vertical-align: middle; width: 15%; text-align: right; border: none;padding-right: 10px;"> |
| 189 |
<?php $this->renderHeaderOrderDate(); ?> |
| 190 |
</td> |
| 191 |
<td |
| 192 |
class="fct-receipt-header-invoice-no" |
| 193 |
style="width:15%;text-align:right;border:none;vertical-align:baseline;"> |
| 194 |
<?php $this->renderHeaderInvoiceNo(); ?> |
| 195 |
</td> |
| 196 |
</tr> |
| 197 |
</tbody> |
| 198 |
</table> |
| 199 |
<?php |
| 200 |
} |
| 201 |
|
| 202 |
public function renderHeaderLogo() |
| 203 |
{ |
| 204 |
?> |
| 205 |
<h1 style="font-size:24px;font-weight:700;color:rgb(17,24,39);margin:0px"> |
| 206 |
<?php |
| 207 |
$imageLink = $this->settings->get('store_logo.url'); |
| 208 |
$storeName = $this->settings->get('store_name'); |
| 209 |
if (empty($imageLink)) { |
| 210 |
echo esc_html($storeName); |
| 211 |
} else { |
| 212 |
echo "<img src=".esc_url($imageLink)." alt=".esc_attr($storeName)." style='max-height: 40px;'>"; |
| 213 |
} |
| 214 |
?> |
| 215 |
</h1> |
| 216 |
<?php |
| 217 |
} |
| 218 |
|
| 219 |
public function renderStoreTaxInformation() |
| 220 |
{ |
| 221 |
$order = Arr::get($this->config, 'order', null); |
| 222 |
$orderTaxRates = $order->getPrimaryOrderTaxRate(); |
| 223 |
$storeVatNumber = Arr::get($orderTaxRates->meta ?? [], 'store_vat_number', ''); |
| 224 |
$taxcountry = Arr::get($orderTaxRates->meta ?? [], 'tax_country', ''); |
| 225 |
if (!empty($storeVatNumber)): ?> |
| 226 |
<span class="fct_invoice_tax_content" style="font-weight: 500; font-size: 14px;"> |
| 227 |
<?php echo esc_html(TaxModule::getCountryTaxTitle($taxcountry)); ?>: |
| 228 |
<?php |
| 229 |
if ($storeVatNumber !== '') { |
| 230 |
echo esc_html($storeVatNumber); |
| 231 |
} |
| 232 |
?> |
| 233 |
</span> |
| 234 |
<?php endif; |
| 235 |
} |
| 236 |
|
| 237 |
public function renderHeaderOrderDate() |
| 238 |
{ |
| 239 |
$order = Arr::get($this->config, 'order', null); |
| 240 |
?> |
| 241 |
<p style="white-space: nowrap; color: #94a3b8; text-align: right; margin: 0;font-size:12px;print-color-adjust: exact;"> |
| 242 |
<?php echo esc_html__('Order At', 'fluent-cart'); ?> |
| 243 |
</p> |
| 244 |
<p style="white-space: nowrap; font-weight: bold; color: #000; text-align: right; margin: 0;font-size:14px;"> |
| 245 |
<?php |
| 246 |
$date = wp_date( |
| 247 |
get_option('date_format'), |
| 248 |
DateTime::anyTimeToGmt($order->created_at)->getTimestamp(), |
| 249 |
new \DateTimeZone($this->orderTz) |
| 250 |
); |
| 251 |
echo esc_html(Helper::translateNumber($date)); |
| 252 |
?> |
| 253 |
</p> |
| 254 |
<?php |
| 255 |
} |
| 256 |
|
| 257 |
public function renderHeaderInvoiceNo() |
| 258 |
{ |
| 259 |
$order = Arr::get($this->config, 'order', null); |
| 260 |
?> |
| 261 |
<p style="white-space: nowrap; color: #94a3b8; text-align: right; margin: 0;font-size:12px;print-color-adjust: exact;"> |
| 262 |
<?php echo esc_html__('Invoice number #', 'fluent-cart'); ?> |
| 263 |
</p> |
| 264 |
<p id="fct-order-invoice-no" |
| 265 |
style="white-space: nowrap; font-weight: bold; color: #000; text-align: right; margin: 0;font-size:14px;"> |
| 266 |
<?php echo esc_html($order->invoice_no); ?> |
| 267 |
</p> |
| 268 |
<?php |
| 269 |
} |
| 270 |
|
| 271 |
public function renderAddresses() |
| 272 |
{ |
| 273 |
$order = Arr::get($this->config, 'order', null); |
| 274 |
?> |
| 275 |
|
| 276 |
<?php if ($order->fulfillment_type === 'physical') : ?> |
| 277 |
<div |
| 278 |
class="fct-receipt-page-store-address" |
| 279 |
style="background: #f8f9fa;padding: 15px;margin-bottom: 20px;print-color-adjust: exact;"> |
| 280 |
<?php $this->renderStoreAddress(); ?> |
| 281 |
</div> |
| 282 |
<?php endif; ?> |
| 283 |
<div |
| 284 |
class="fct-receipt-page-order-items-addresses" |
| 285 |
style="display: grid;grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));gap: 20px;"> |
| 286 |
<?php if ($order->fulfillment_type === 'digital') : ?> |
| 287 |
<div |
| 288 |
class="fct-receipt-page-store-address" |
| 289 |
style="border-radius: 5px;print-color-adjust: exact;"> |
| 290 |
<?php $this->renderStoreAddress(true); ?> |
| 291 |
</div> |
| 292 |
<?php endif; ?> |
| 293 |
<?php $this->renderBillToAddress(); ?> |
| 294 |
<?php if ($order->fulfillment_type === 'physical') : ?> |
| 295 |
<?php $this->renderShipToAddress(); ?> |
| 296 |
<?php endif; ?> |
| 297 |
</div> |
| 298 |
<?php |
| 299 |
} |
| 300 |
|
| 301 |
public function renderStoreAddress($title_border = false) |
| 302 |
{ |
| 303 |
$order = Arr::get($this->config, 'order', null); |
| 304 |
?> |
| 305 |
<?php if ($title_border) : ?> |
| 306 |
<h5 |
| 307 |
class="fct-receipt-page-store-address-name" |
| 308 |
style="font-weight: bold;font-size: 14px;margin: 0 0 10px 0;color: #495057;border-bottom: 1px solid #dee2e6;padding-bottom: 5px;"> |
| 309 |
<?php echo esc_html($this->settings->get('store_name')); ?> |
| 310 |
</h5> |
| 311 |
<?php else: ?> |
| 312 |
<div |
| 313 |
class="fct-receipt-page-store-address-name" |
| 314 |
style="font-size: 18px;font-weight: bold;margin-bottom: 8px;"> |
| 315 |
<?php echo esc_html($this->settings->get('store_name')); ?> |
| 316 |
</div> |
| 317 |
<?php endif; ?> |
| 318 |
<div |
| 319 |
class="fct-receipt-page-store-address-address" |
| 320 |
style="margin-bottom: 3px;"> |
| 321 |
<?php echo esc_html($this->settings->getFormattedFullAddress()); ?> |
| 322 |
</div> |
| 323 |
<?php |
| 324 |
$orderTaxRates = $order->getPrimaryOrderTaxRate(); |
| 325 |
$storeVatNumber = Arr::get($orderTaxRates->meta ?? [], 'store_vat_number', ''); |
| 326 |
$taxCountry = Arr::get($orderTaxRates->meta ?? [], 'tax_country', ''); |
| 327 |
if (!empty($storeVatNumber)): ?> |
| 328 |
<div |
| 329 |
class="fct-receipt-page-store-address-vat" |
| 330 |
style="margin-top: 5px;font-weight: 500;"> |
| 331 |
<?php echo esc_html(TaxModule::getCountryTaxTitle($taxCountry)) . ': ' . esc_html($storeVatNumber); ?> |
| 332 |
</div> |
| 333 |
<?php endif; |
| 334 |
} |
| 335 |
|
| 336 |
public function renderBillToAddress() |
| 337 |
{ |
| 338 |
$order = Arr::get($this->config, 'order', null); |
| 339 |
$orderTaxRates = $order->getPrimaryOrderTaxRate(); |
| 340 |
?> |
| 341 |
<div |
| 342 |
class="fct-receipt-page-order-items-addresses-bill-to" |
| 343 |
style="border-radius: 5px;print-color-adjust: exact;"> |
| 344 |
<h5 |
| 345 |
class="fct-receipt-page-order-items-addresses-bill-to-title" |
| 346 |
style="font-weight: bold;font-size: 14px;margin: 0 0 10px 0;color: #495057;border-bottom: 1px solid #dee2e6;padding-bottom: 5px;"> |
| 347 |
<?php echo esc_html__('Bill To', 'fluent-cart'); ?> |
| 348 |
</h5> |
| 349 |
<?php if (!empty($order->billing_address)) : ?> |
| 350 |
|
| 351 |
<div |
| 352 |
class="fct-receipt-page-order-items-addresses-bill-to-address" |
| 353 |
style="margin-bottom: 3px;"> |
| 354 |
<?php echo esc_html($order->billing_address->getAddressAsText()); ?> |
| 355 |
</div> |
| 356 |
<div |
| 357 |
class="fct-receipt-page-order-items-addresses-bill-to-email" |
| 358 |
style="margin-top: 10px;"> |
| 359 |
<?php echo esc_html($order->customer->email); ?> |
| 360 |
|
| 361 |
</div> |
| 362 |
<?php |
| 363 |
$phoneNumber = Arr::get($order->billing_address->meta ?? [], 'other_data.phone', ''); |
| 364 |
if ($phoneNumber !== ''): |
| 365 |
?> |
| 366 |
<div |
| 367 |
class="fct-receipt-page-order-items-addresses-bill-to-phone" |
| 368 |
style="margin-top: 3px;"> |
| 369 |
<?php echo esc_html($phoneNumber); ?> |
| 370 |
</div> |
| 371 |
<?php endif; ?> |
| 372 |
<?php |
| 373 |
$companyName = Arr::get($order->billing_address->meta ?? [], 'other_data.company_name', ''); |
| 374 |
if ($companyName === '') { |
| 375 |
$companyName = $order->getCustomerTaxName(); |
| 376 |
} |
| 377 |
if ($companyName !== ''): |
| 378 |
?> |
| 379 |
<div class="fct-receipt-page-order-items-addresses-bill-to-company-name"> |
| 380 |
<?php echo esc_html($companyName); ?> |
| 381 |
</div> |
| 382 |
<?php endif; ?> |
| 383 |
<?php |
| 384 |
$legalRegId = Arr::get($order->billing_address->meta ?? [], 'other_data.legal_registration_id', ''); |
| 385 |
if ($legalRegId === '') { |
| 386 |
$legalRegId = Arr::get($order->getBusinessInfo(), 'legal_registration_id', ''); |
| 387 |
} |
| 388 |
if ($legalRegId !== ''): |
| 389 |
?> |
| 390 |
<div class="fct-receipt-page-order-items-addresses-bill-to-legal-reg" style="margin-top: 3px;"> |
| 391 |
<?php echo esc_html__('Reg. ID', 'fluent-cart') . ': ' . esc_html($legalRegId); ?> |
| 392 |
</div> |
| 393 |
<?php endif; ?> |
| 394 |
<div |
| 395 |
class="fct-receipt-page-order-items-addresses-bill-to-vat-number" |
| 396 |
style="margin-top: 5px;"> |
| 397 |
<?php |
| 398 |
$vatNumber = $order->getCustomerTaxNumber(); |
| 399 |
if ($vatNumber !== '') { |
| 400 |
$vatLabel = __('VAT/Tax ID', 'fluent-cart'); |
| 401 |
echo esc_html($vatLabel) . ': ' . esc_html($vatNumber); |
| 402 |
} |
| 403 |
?> |
| 404 |
</div> |
| 405 |
<?php |
| 406 |
$reverseChargeDeclaration = Arr::get($order->getBusinessInfo(), 'reverse_charge_declaration', ''); |
| 407 |
if ($reverseChargeDeclaration !== ''): |
| 408 |
?> |
| 409 |
<div class="fct-receipt-page-order-items-addresses-bill-to-reverse-charge" style="margin-top: 5px;"> |
| 410 |
<strong><?php echo esc_html__('Reverse Charge Declaration', 'fluent-cart'); ?>:</strong> |
| 411 |
<?php echo esc_html($reverseChargeDeclaration); ?> |
| 412 |
</div> |
| 413 |
<?php endif; ?> |
| 414 |
|
| 415 |
<?php else: ?> |
| 416 |
<div |
| 417 |
class="fct-receipt-page-order-items-addresses-bill-to-name" |
| 418 |
style="margin-top: 10px;"> |
| 419 |
<?php echo esc_html($order->customer->full_name); ?> |
| 420 |
</div> |
| 421 |
<div |
| 422 |
class="fct-receipt-page-order-items-addresses-bill-to-email" |
| 423 |
style="margin-top: 3px;"> |
| 424 |
<?php echo esc_html($order->customer->email); ?> |
| 425 |
</div> |
| 426 |
<?php endif; ?> |
| 427 |
</div> |
| 428 |
<?php |
| 429 |
} |
| 430 |
|
| 431 |
public function renderShipToAddress() |
| 432 |
{ |
| 433 |
$order = Arr::get($this->config, 'order', null); |
| 434 |
?> |
| 435 |
<div |
| 436 |
class="fct-receipt-page-order-items-addresses-ship-to" |
| 437 |
style="border-radius: 5px;print-color-adjust: exact;"> |
| 438 |
<h5 |
| 439 |
class="fct-receipt-page-order-items-addresses-ship-to-title" |
| 440 |
style="font-weight: bold;font-size: 14px;margin: 0 0 10px 0;color: #495057;border-bottom: 1px solid #dee2e6;padding-bottom: 5px;"> |
| 441 |
<?php echo esc_html__('Ship To', 'fluent-cart'); ?> |
| 442 |
</h5> |
| 443 |
<?php if (!empty($order->shipping_address)) : ?> |
| 444 |
<div |
| 445 |
class="fct-receipt-page-order-items-addresses-ship-to-address" |
| 446 |
style="margin-bottom: 3px;"> |
| 447 |
<?php echo esc_html($order->shipping_address->getAddressAsText()); ?> |
| 448 |
</div> |
| 449 |
<?php |
| 450 |
$phone = Arr::get($order->shipping_address->meta ?? [], 'other_data.phone', ''); |
| 451 |
if ($phone !== ''): |
| 452 |
?> |
| 453 |
<div |
| 454 |
class="fct-receipt-page-order-items-addresses-ship-to-phone" |
| 455 |
style="margin-top: 3px;"> |
| 456 |
<?php echo esc_html($phone); ?> |
| 457 |
</div> |
| 458 |
<?php endif; ?> |
| 459 |
<?php else: ?> |
| 460 |
<div |
| 461 |
class="fct-receipt-page-order-items-addresses-ship-to-name" |
| 462 |
style="margin-top: 10px;"> |
| 463 |
<?php echo esc_html($order->customer->full_name); ?> |
| 464 |
</div> |
| 465 |
<div |
| 466 |
class="fct-receipt-page-order-items-addresses-ship-to-email" |
| 467 |
style="margin-top: 3px;"> |
| 468 |
<?php echo esc_html($order->customer->email); ?> |
| 469 |
</div> |
| 470 |
<?php endif; ?> |
| 471 |
</div> |
| 472 |
<?php |
| 473 |
} |
| 474 |
|
| 475 |
public function renderOrderItems() |
| 476 |
{ |
| 477 |
$order = Arr::get($this->config, 'order', null); |
| 478 |
if ($order->order_items) : ?> |
| 479 |
<?php $this->renderOrderItemsTable(); ?> |
| 480 |
|
| 481 |
<?php $this->renderOrderItemsFooter(); ?> |
| 482 |
<?php endif; |
| 483 |
} |
| 484 |
|
| 485 |
public function renderOrderItemsTable() |
| 486 |
{ |
| 487 |
$order = Arr::get($this->config, 'order', null); |
| 488 |
if ($order->order_items) : ?> |
| 489 |
<table |
| 490 |
class="fct-receipt-page-order-items-table" |
| 491 |
style="margin-top: 20px;margin-bottom: 10px;width: 100%;text-align: left;border-spacing: 0;border-collapse: collapse;border: none;"> |
| 492 |
<thead> |
| 493 |
<tr> |
| 494 |
<th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;print-color-adjust: exact;border: none;"> |
| 495 |
<?php echo esc_html__('Description', 'fluent-cart'); ?> |
| 496 |
</th> |
| 497 |
<th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;width: 80px;text-align: right;print-color-adjust: exact;border: none;"> |
| 498 |
<?php echo esc_html__('Qty', 'fluent-cart'); ?> |
| 499 |
</th> |
| 500 |
<th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;width: 80px;text-align: right;print-color-adjust: exact;border: none;"> |
| 501 |
<?php echo esc_html__('Unit price', 'fluent-cart'); ?> |
| 502 |
</th> |
| 503 |
<th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;width: 80px;text-align: right;print-color-adjust: exact;border: none;"> |
| 504 |
<?php echo esc_html__('Amount', 'fluent-cart'); ?> |
| 505 |
</th> |
| 506 |
</tr> |
| 507 |
</thead> |
| 508 |
<tbody> |
| 509 |
<?php |
| 510 |
$orderItems = $order->order_items->toArray(); |
| 511 |
$isReversed = $order->isReverseChargeTaxOrder(); |
| 512 |
$rcMode = $order->getOrderRcMode(); |
| 513 |
$fctReceiptTaxDisplayMode = TaxSummaryHelper::getTaxDisplayMode(); |
| 514 |
|
| 515 |
foreach ($orderItems as $item) : |
| 516 |
if (($item['payment_type'] ?? '') === 'fee') { |
| 517 |
continue; |
| 518 |
} |
| 519 |
$itemRates = TaxSummaryHelper::getItemTaxRates($item); |
| 520 |
$itemBorder = empty($itemRates) ? '1px solid #dee2e6' : 'none'; |
| 521 |
?> |
| 522 |
<tr> |
| 523 |
<td style="font-size:15px;padding: 12px 8px;border: none;border-bottom: <?php echo esc_attr($itemBorder); ?>;print-color-adjust: exact;"> |
| 524 |
<?php echo esc_html($item['post_title']); ?> |
| 525 |
<br> |
| 526 |
<?php if (!empty($item['title'])) : ?> |
| 527 |
<small style="font-size: 13px;color: #758195;">- <?php echo esc_html(!empty($item['variation_display_title']) ? $item['variation_display_title'] : $item['title']); ?></small> |
| 528 |
<br> |
| 529 |
<?php endif; ?> |
| 530 |
<?php if (!empty($item['payment_info'])) : ?> |
| 531 |
<small style="font-size: 13px;color: #758195;"><?php echo esc_html($item['payment_info']); ?></small> |
| 532 |
<?php endif; ?> |
| 533 |
<?php if ($fctReceiptTaxDisplayMode !== 'simplified' && empty($itemRates) && !empty($item['tax_amount'])) : ?> |
| 534 |
<small style="font-size: 12px; color: #94a3b8; display:block; margin-top:2px;"> |
| 535 |
<?php |
| 536 |
/* translators: %1$s: formatted tax amount */ |
| 537 |
echo esc_html(sprintf(__('Tax: %1$s', 'fluent-cart'), Helper::toDecimal((int) $item['tax_amount']))); ?> |
| 538 |
</small> |
| 539 |
<?php endif; ?> |
| 540 |
</td> |
| 541 |
<td style="padding: 12px 8px;border: none;border-bottom: <?php echo esc_attr($itemBorder); ?>;text-align: right; vertical-align: top;"> |
| 542 |
<?php echo esc_html(Helper::translateNumber($item['quantity'])); ?> |
| 543 |
</td> |
| 544 |
<?php $couponDiscount = (int) Arr::get($item['line_meta'] ?? [], 'coupon_discount', 0); ?> |
| 545 |
<td style="padding: 12px 8px;border: none;border-bottom: <?php echo esc_attr($itemBorder); ?>;text-align: right; vertical-align: top;"> |
| 546 |
<?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice($item['unit_price'], null, false, true, true)); ?> |
| 547 |
</td> |
| 548 |
<td style="padding: 12px 8px;border: none;border-bottom: <?php echo esc_attr($itemBorder); ?>;text-align: right; vertical-align: top;"> |
| 549 |
<?php if ($couponDiscount > 0): ?> |
| 550 |
<span style="text-decoration:line-through;opacity:0.5;font-size:11px;display:block;"> |
| 551 |
<?php echo esc_html(Helper::toDecimal($item['subtotal'])); ?> |
| 552 |
</span> |
| 553 |
<?php endif; ?> |
| 554 |
<?php echo esc_html($item['formatted_total']); ?> |
| 555 |
</td> |
| 556 |
</tr> |
| 557 |
<?php if ($fctReceiptTaxDisplayMode !== 'simplified' && !empty($itemRates)) : ?> |
| 558 |
<tr> |
| 559 |
<td colspan="4" style="padding:0 8px 8px 8px;border:none;border-bottom:1px solid #dee2e6;"> |
| 560 |
<?php echo $this->renderTaxRatePills($itemRates, $isReversed, $rcMode); ?> |
| 561 |
</td> |
| 562 |
</tr> |
| 563 |
<?php endif; ?> |
| 564 |
<?php endforeach; ?> |
| 565 |
</tbody> |
| 566 |
</table> |
| 567 |
<?php endif; |
| 568 |
} |
| 569 |
|
| 570 |
public function renderOrderItemsFooter() |
| 571 |
{ |
| 572 |
$order = Arr::get($this->config, 'order', null); |
| 573 |
?> |
| 574 |
<div |
| 575 |
class="fct-receipt-page-order-items-footer" |
| 576 |
style="margin-top: 20px;"> |
| 577 |
<table |
| 578 |
class="fct-receipt-page-order-items-footer-table" |
| 579 |
style="max-width: 250px;width: 100%;margin-left: auto;border-collapse: collapse;background: #f8f9fa;print-color-adjust: exact;border: none; border-radius: 8px;"> |
| 580 |
<tbody> |
| 581 |
<?php $this->renderSubtotal(); ?> |
| 582 |
<?php $this->renderDiscount(); ?> |
| 583 |
<?php $this->renderShipping(); ?> |
| 584 |
<?php $this->renderFees(); ?> |
| 585 |
<?php $this->renderTaxSummaryBox(); ?> |
| 586 |
<?php $this->renderProrateCredit(); ?> |
| 587 |
<?php $this->renderRefund(); ?> |
| 588 |
<?php $this->renderTotal(); ?> |
| 589 |
<?php $this->renderAmountPaid(); ?> |
| 590 |
</tbody> |
| 591 |
</table> |
| 592 |
</div> |
| 593 |
<?php |
| 594 |
} |
| 595 |
|
| 596 |
public function renderSubtotal() |
| 597 |
{ |
| 598 |
$order = Arr::get($this->config, 'order', null); |
| 599 |
if ($order->subtotal != ($order->total_amount - $order->total_refund) || $order->tax_total > 0): ?> |
| 600 |
<tr> |
| 601 |
<td style="text-align: right;border: none; padding-top: 20px;"> |
| 602 |
<?php echo esc_html__('Subtotal', 'fluent-cart'); ?> |
| 603 |
</td> |
| 604 |
<td style="font-weight:700; padding-right: 8px; padding-top: 20px;width: 100px;text-align: right;border: none;"> |
| 605 |
<?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->subtotal)); |
| 606 |
?> |
| 607 |
</td> |
| 608 |
</tr> |
| 609 |
<?php endif; |
| 610 |
} |
| 611 |
|
| 612 |
public function renderDiscount() |
| 613 |
{ |
| 614 |
$order = Arr::get($this->config, 'order', null); |
| 615 |
$prorateCredit = (int) \FluentCart\Framework\Support\Arr::get($order->config, 'prorate_credit', 0); |
| 616 |
$upgradeDiscount = $order->manual_discount_total - $prorateCredit; |
| 617 |
// When the prorate credit IS the whole discount, label the row directly |
| 618 |
// instead of showing "Discount" with a single redundant breakdown row. |
| 619 |
$onlyProrateCredit = $prorateCredit > 0 && $upgradeDiscount <= 0 && $order->coupon_discount_total <= 0; |
| 620 |
|
| 621 |
if ($order->manual_discount_total + $order->coupon_discount_total > 0): ?> |
| 622 |
<tr> |
| 623 |
<td style="text-align: right;border: none;"> |
| 624 |
<?php echo $onlyProrateCredit ? esc_html__('Prorate Credit', 'fluent-cart') : esc_html__('Discount', 'fluent-cart'); ?> |
| 625 |
</td> |
| 626 |
<td style="padding-right:8px; width: 100px;text-align: right;border: none;"> |
| 627 |
- <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->manual_discount_total + $order->coupon_discount_total)); ?> |
| 628 |
</td> |
| 629 |
</tr> |
| 630 |
<?php if ($prorateCredit > 0 && $upgradeDiscount > 0): ?> |
| 631 |
<tr> |
| 632 |
<td style="padding-left:20px;text-align: right;border: none;font-size:12px;color:rgb(107,114,128);"> |
| 633 |
<?php echo esc_html__('Upgrade Discount', 'fluent-cart'); ?> |
| 634 |
</td> |
| 635 |
<td style="padding-right:8px;width: 100px;text-align: right;border: none;font-size:12px;color:rgb(107,114,128);"> |
| 636 |
<?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($upgradeDiscount)); ?> |
| 637 |
</td> |
| 638 |
</tr> |
| 639 |
<?php endif; ?> |
| 640 |
<?php if ($prorateCredit > 0 && !$onlyProrateCredit): ?> |
| 641 |
<tr> |
| 642 |
<td style="padding-left:20px;text-align: right;border: none;font-size:12px;color:rgb(107,114,128);"> |
| 643 |
<?php echo esc_html__('Prorate Credit', 'fluent-cart'); ?> |
| 644 |
</td> |
| 645 |
<td style="padding-right:8px;width: 100px;text-align: right;border: none;font-size:12px;color:rgb(107,114,128);"> |
| 646 |
<?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($prorateCredit)); ?> |
| 647 |
</td> |
| 648 |
</tr> |
| 649 |
<?php endif; ?> |
| 650 |
<?php endif; |
| 651 |
} |
| 652 |
|
| 653 |
public function renderProrateCredit() |
| 654 |
{ |
| 655 |
// Rendered as a sub-row inside renderDiscount. |
| 656 |
} |
| 657 |
|
| 658 |
public function renderShipping() |
| 659 |
{ |
| 660 |
$order = Arr::get($this->config, 'order', null); |
| 661 |
if ($order->shipping_total <= 0) { |
| 662 |
return; |
| 663 |
} |
| 664 |
$displayShipping = (int) $order->shipping_total; |
| 665 |
if ($order->isReverseChargeTaxOrder()) { |
| 666 |
$rcAdj = (int) Arr::get($this->getMemoizedTaxSummary($order), 'rcShippingAdjustment', 0); |
| 667 |
if ($rcAdj > 0) { |
| 668 |
$displayShipping = max(0, $displayShipping - $rcAdj); |
| 669 |
} |
| 670 |
} |
| 671 |
$shippingMethodTitle = (string) Arr::get($order->config, 'shipping_method_title', ''); |
| 672 |
?> |
| 673 |
<tr> |
| 674 |
<td style="padding: 8px 20px 8px 0;text-align: right;border: none;"> |
| 675 |
<?php echo esc_html__('Shipping', 'fluent-cart'); ?> |
| 676 |
<?php if ($shippingMethodTitle): ?> |
| 677 |
<span style="display:block;font-size:12px;color:rgb(107,114,128);line-height:18px;"> |
| 678 |
<?php echo esc_html($shippingMethodTitle); ?> |
| 679 |
</span> |
| 680 |
<?php endif; ?> |
| 681 |
</td> |
| 682 |
<td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;"> |
| 683 |
<?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($displayShipping)); ?> |
| 684 |
</td> |
| 685 |
</tr> |
| 686 |
<?php |
| 687 |
} |
| 688 |
|
| 689 |
public function renderFees() |
| 690 |
{ |
| 691 |
$order = Arr::get($this->config, 'order', null); |
| 692 |
if (!$order || $order->fee_total <= 0) { |
| 693 |
return; |
| 694 |
} |
| 695 |
$feeItems = $order->feeItems()->get(); |
| 696 |
foreach ($feeItems as $feeItem): ?> |
| 697 |
<tr> |
| 698 |
<td style="padding: 8px 20px 8px 0;text-align: right;border: none;"> |
| 699 |
<?php echo esc_html($feeItem->title); ?> |
| 700 |
</td> |
| 701 |
<td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border: none;"> |
| 702 |
<?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($feeItem->subtotal)); ?> |
| 703 |
</td> |
| 704 |
</tr> |
| 705 |
<?php endforeach; |
| 706 |
} |
| 707 |
|
| 708 |
public function renderRefund() |
| 709 |
{ |
| 710 |
$order = Arr::get($this->config, 'order', null); |
| 711 |
if ($order->total_refund > 0): ?> |
| 712 |
<tr style="font-weight: bold;font-size: 14px;"> |
| 713 |
<td style="font-weight:500;padding: 8px 20px 8px 0;text-align: right;border:none;"> |
| 714 |
<?php echo esc_html__('Refund', 'fluent-cart'); ?> |
| 715 |
</td> |
| 716 |
<td style="padding: 8px 8px 8px 0;width: 100px;text-align: right;border:none;"> |
| 717 |
- <?php echo esc_html(\FluentCart\App\Helpers\Helper::toDecimal($order->total_refund)); ?> |
| 718 |
</td> |
| 719 |
</tr> |
| 720 |
<?php endif; |
| 721 |
} |
| 722 |
|
| 723 |
public function renderTotal() |
| 724 |
{ |
| 725 |
$order = Arr::get($this->config, 'order', null); |
| 726 |
$displayTotal = (int) $order->total_amount - (int) $order->total_refund; |
| 727 |
if ($order->isReverseChargeTaxOrder()) { |
| 728 |
$rcAdj = (int) Arr::get($this->getMemoizedTaxSummary($order), 'rcTotalAdjustment', 0); |
| 729 |
if ($rcAdj > 0) { |
| 730 |
$displayTotal = max(0, $displayTotal - $rcAdj); |
| 731 |
} |
| 732 |
} |
| 733 |
?> |
| 734 |
<tr style="font-weight: bold;font-size: 14px;"> |
| 735 |
<td style="font-weight:500;text-align: right;border:none;"> |
| 736 |
<?php echo esc_html__('Total', 'fluent-cart'); ?> |
| 737 |
</td> |
| 738 |
<td style="width: 100px;text-align: right;border:none; padding-right: 8px;"> |
| 739 |
<?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice($displayTotal, null, false, true, true)); ?> |
| 740 |
</td> |
| 741 |
</tr> |
| 742 |
<?php |
| 743 |
} |
| 744 |
|
| 745 |
public function renderAmountPaid() |
| 746 |
{ |
| 747 |
$order = Arr::get($this->config, 'order', null); |
| 748 |
?> |
| 749 |
<tr style="font-weight: bold;font-size: 14px;"> |
| 750 |
<td style="font-weight:500;text-align: right;border:none; padding-bottom: 20px"> |
| 751 |
<?php echo esc_html__('Amount Paid', 'fluent-cart'); ?> |
| 752 |
</td> |
| 753 |
<td style="width: 100px;text-align: right;border:none;padding-bottom: 20px; padding-right: 8px;"> |
| 754 |
<?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice(($order->total_paid - $order->total_refund), null, false, true, true)); ?> |
| 755 |
</td> |
| 756 |
</tr> |
| 757 |
<?php |
| 758 |
} |
| 759 |
|
| 760 |
public function renderTaxNote() |
| 761 |
{ |
| 762 |
$order = Arr::get($this->config, 'order', null); |
| 763 |
if ($order->isReverseChargeTaxOrder()): ?> |
| 764 |
|
| 765 |
<div style="text-align: right; font-size: 14px; margin-top: 10px;"> |
| 766 |
<?php echo '*' . esc_html(TaxModule::getReverseChargeNoticeText()); ?> |
| 767 |
</div> |
| 768 |
|
| 769 |
<?php endif; |
| 770 |
} |
| 771 |
|
| 772 |
public function renderPaymentHistory() |
| 773 |
{ |
| 774 |
$order = Arr::get($this->config, 'order', null); |
| 775 |
$transactions = $order->transactions; |
| 776 |
if (!empty($transactions)) : |
| 777 |
?> |
| 778 |
<div |
| 779 |
class="fct-payment-history" |
| 780 |
style="margin-top: 30px;"> |
| 781 |
<div |
| 782 |
class="fct-payment-history-heading" |
| 783 |
style="font-weight: bold;font-size: 14px;color: #495057;margin: 0;padding: 0;"> |
| 784 |
<?php echo esc_html__('Payment history', 'fluent-cart'); ?> |
| 785 |
</div> |
| 786 |
<table class="fct-transaction-table" |
| 787 |
style="margin-top: 10px;width: 100%;text-align: left;border-spacing: 0;border-collapse: collapse;border: none;"> |
| 788 |
<thead> |
| 789 |
<tr> |
| 790 |
<th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold;print-color-adjust: exact;border:none;"> |
| 791 |
<?php echo esc_html__('Payment method', 'fluent-cart'); ?> |
| 792 |
</th> |
| 793 |
<th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold; text-align: center;print-color-adjust: exact;border:none;"> |
| 794 |
<?php echo esc_html__('Date', 'fluent-cart'); ?> |
| 795 |
</th> |
| 796 |
<th style="background-color: #f8f9fa;padding: 12px 8px;font-weight: bold; text-align: right;print-color-adjust: exact;border:none;"> |
| 797 |
<?php echo esc_html__('Amount', 'fluent-cart'); ?> |
| 798 |
</th> |
| 799 |
</tr> |
| 800 |
</thead> |
| 801 |
<tbody> |
| 802 |
<?php foreach ($transactions as $transaction) : |
| 803 |
if ($transaction->transaction_type === 'refund') { |
| 804 |
continue; |
| 805 |
} |
| 806 |
?> |
| 807 |
<tr> |
| 808 |
<td style="padding: 10px;border:none;border-bottom: 1px solid #dee2e6;"> |
| 809 |
<?php echo esc_html($transaction->getPaymentMethodText()); ?> |
| 810 |
</td> |
| 811 |
<td style="padding: 10px;border:none;border-bottom: 1px solid #dee2e6;text-align: center;"> |
| 812 |
<?php |
| 813 |
$date = wp_date( |
| 814 |
get_option('date_format'), |
| 815 |
DateTime::anyTimeToGmt($transaction->created_at)->getTimestamp(), |
| 816 |
new \DateTimeZone($this->orderTz) |
| 817 |
); |
| 818 |
echo esc_html(Helper::translateNumber($date)); |
| 819 |
?> |
| 820 |
</td> |
| 821 |
<td style="padding: 10px;border:none;border-bottom: 1px solid #dee2e6;text-align: right;"> |
| 822 |
<?php echo esc_html(\FluentCart\Api\CurrencySettings::getFormattedPrice($transaction->total, null, false, true, true)); ?> |
| 823 |
</td> |
| 824 |
</tr> |
| 825 |
<?php endforeach; ?> |
| 826 |
</tbody> |
| 827 |
</table> |
| 828 |
</div> |
| 829 |
<?php endif; |
| 830 |
} |
| 831 |
|
| 832 |
public function renderConfirmationError($errorData) |
| 833 |
{ |
| 834 |
$failed_reason = Arr::get($errorData, 'failed_reason', ''); |
| 835 |
$custom_payment_url = Arr::get($errorData, 'custom_payment_url', ''); |
| 836 |
?> |
| 837 |
<style> |
| 838 |
.fluent_cart_confirmation_failed { |
| 839 |
max-width: 700px; |
| 840 |
margin: 0 auto; |
| 841 |
padding: 30px; |
| 842 |
border-radius: 9px; |
| 843 |
box-shadow: 1px 1px 5px 0px #ccc; |
| 844 |
border-left: 3px solid red; |
| 845 |
} |
| 846 |
</style> |
| 847 |
<div class="fluent_cart_confirmation_failed"> |
| 848 |
<h3><?php echo esc_html__('Payment Confirmation Failed!', 'fluent-cart'); ?></h3> |
| 849 |
<span><?php echo esc_html__('We are sorry, your order is placed but payment confirmation has failed.', 'fluent-cart'); ?></span> |
| 850 |
<?php if ($failed_reason) : ?> |
| 851 |
<p style="color:red;font-style: italic;"><?php echo esc_html__('Failure reason: ', 'fluent-cart') . esc_html($failed_reason) ?></p> |
| 852 |
<?php endif; ?> |
| 853 |
<span><?php echo esc_html__('Please try to complete payment again from here!', 'fluent-cart'); ?></span> |
| 854 |
<a href="<?php echo esc_url($custom_payment_url ?? ''); ?>"><?php echo esc_url($custom_payment_url); ?></a> |
| 855 |
</div> |
| 856 |
<?php } |
| 857 |
|
| 858 |
private function renderTaxRatePills(array $rates, bool $isReversed = false, string $rcMode = 'fixed') |
| 859 |
{ |
| 860 |
$html = ''; |
| 861 |
foreach ($rates as $rate) { |
| 862 |
$isInclusive = !empty($rate['inclusive']); |
| 863 |
$badgeBg = $isInclusive ? '#EAF3DE' : '#FAEEDA'; |
| 864 |
$textColor = $isInclusive ? '#3B6D11' : '#854F0B'; |
| 865 |
$shouldStrike = $isReversed && (!$isInclusive || $rcMode === 'dynamic'); |
| 866 |
$amountStyle = 'color:' . esc_attr($textColor) . ';font-size:11px;font-weight:500;' |
| 867 |
. ($shouldStrike ? 'text-decoration:line-through;opacity:0.6;' : ''); |
| 868 |
/* translators: %1$s: formatted tax amount (e.g. $12.00) */ |
| 869 |
$amountDisplay = $isInclusive |
| 870 |
? esc_html(sprintf(__('incl. %1$s', 'fluent-cart'), Helper::toDecimal($rate['tax_amount']))) |
| 871 |
: esc_html(Helper::toDecimal($rate['tax_amount'])); |
| 872 |
$html .= '<table width="100%" cellpadding="0" cellspacing="0" style="border:none;margin-top:3px;">'; |
| 873 |
$html .= '<tr>'; |
| 874 |
$html .= '<td style="padding:0;border:none;">'; |
| 875 |
$html .= '<span style="background-color:' . esc_attr($badgeBg) . ';color:' . esc_attr($textColor) . ';font-size:11px;padding:2px 7px;border-radius:4px;display:inline-block;">' . esc_html($rate['label']) . ' (' . esc_html(number_format((float) $rate['rate_percent'], 0)) . '%)</span>'; |
| 876 |
$html .= '</td>'; |
| 877 |
$html .= '<td style="text-align:right;padding:0;border:none;white-space:nowrap;">'; |
| 878 |
$html .= '<span style="' . $amountStyle . '">' . $amountDisplay . '</span>'; |
| 879 |
$html .= '</td>'; |
| 880 |
$html .= '</tr>'; |
| 881 |
$html .= '</table>'; |
| 882 |
} |
| 883 |
return $html; |
| 884 |
} |
| 885 |
|
| 886 |
public function renderTaxSummaryBox() |
| 887 |
{ |
| 888 |
$order = Arr::get($this->config, 'order', null); |
| 889 |
$summary = $this->getMemoizedTaxSummary($order); |
| 890 |
if (!$summary['shouldRender']) { |
| 891 |
return; |
| 892 |
} |
| 893 |
?> |
| 894 |
<tr> |
| 895 |
<td colspan="2" style="padding: 6px 8px;"> |
| 896 |
<table width="100%" cellpadding="0" cellspacing="0" style="border:1px solid #e2e8f0; border-radius:6px; border-collapse:separate; background:#ffffff; -webkit-print-color-adjust:exact; print-color-adjust:exact;"> |
| 897 |
<tr> |
| 898 |
<td style="padding:6px 8px 6px 0;"> |
| 899 |
<table width="100%" cellpadding="0" cellspacing="0" style="border:none;border-collapse:collapse;"> |
| 900 |
<?php if (($summary['displayMode'] ?? '') === 'simplified' && !empty($summary['simpleLine'])): ?> |
| 901 |
<tr> |
| 902 |
<td style="padding:4px 0 3px 8px; font-size:11px; font-weight:600; color:#1e293b; text-align:left;"> |
| 903 |
<?php echo esc_html($summary['simpleLine']['label']); ?> |
| 904 |
</td> |
| 905 |
<td style="padding:4px 0 3px; font-size:11px; font-weight:600; color:#1e293b; text-align:right;"> |
| 906 |
<?php echo esc_html($summary['simpleLine']['value']); ?> |
| 907 |
</td> |
| 908 |
</tr> |
| 909 |
<?php endif; ?> |
| 910 |
<?php if (($summary['displayMode'] ?? '') !== 'simplified'): ?> |
| 911 |
<tr> |
| 912 |
<td colspan="2" style="padding:0 0 3px 0; font-size:10px; font-weight:600; |
| 913 |
text-transform:uppercase; letter-spacing:0.06em; color:#64748b;"> |
| 914 |
<?php if (!empty(Arr::get($summary, 'foldedRateLines', []))): ?> |
| 915 |
<?php echo esc_html__('Tax breakdown by rate', 'fluent-cart'); ?> |
| 916 |
<?php else: ?> |
| 917 |
<?php echo esc_html__('TAX SUMMARY', 'fluent-cart'); ?> |
| 918 |
<?php endif; ?> |
| 919 |
</td> |
| 920 |
</tr> |
| 921 |
<?php |
| 922 |
$foldedRateLines = Arr::get($summary, 'foldedRateLines', []); |
| 923 |
$rcIsReverseCharge = !empty($summary['isReverseCharge']); |
| 924 |
$rcReversedTotal = (int) Arr::get($summary, 'reversedTaxTotal', 0); |
| 925 |
$rcReversedShipping = (int) Arr::get($summary, 'reversedShippingTax', 0); |
| 926 |
$rcReversedValue = $rcReversedTotal > 0 |
| 927 |
? Helper::toDecimal($rcReversedTotal) |
| 928 |
: __('Charge reversed', 'fluent-cart'); |
| 929 |
$includedInPrices = (int) Arr::get($summary, 'includedInPrices', 0); |
| 930 |
?> |
| 931 |
<?php if (!empty($foldedRateLines)): ?> |
| 932 |
<tr> |
| 933 |
<td colspan="2" style="padding:2px 0 0 0;"> |
| 934 |
<table width="100%" cellpadding="0" cellspacing="0" style="border:none;border-collapse:collapse;table-layout:fixed;"> |
| 935 |
<tr> |
| 936 |
<td style="width:58%;padding:3px 8px 3px 8px; font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:0.06em; color:#64748b; vertical-align:top;"> |
| 937 |
<?php echo esc_html__('Rate', 'fluent-cart'); ?> |
| 938 |
</td> |
| 939 |
<td style="width:24%;padding:3px 8px 3px 0; font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:0.06em; color:#64748b; text-align:right; white-space:nowrap; vertical-align:top;"> |
| 940 |
<?php echo esc_html__('Taxable base', 'fluent-cart'); ?> |
| 941 |
</td> |
| 942 |
<td style="width:18%;padding:3px 0 3px; font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:0.06em; color:#64748b; text-align:right; white-space:nowrap; vertical-align:top;"> |
| 943 |
<?php echo esc_html__('Tax', 'fluent-cart'); ?> |
| 944 |
</td> |
| 945 |
</tr> |
| 946 |
<?php foreach ($foldedRateLines as $foldedRow): |
| 947 |
$foldedColor = !empty($foldedRow['inclusive']) ? '#94a3b8' : '#334155'; ?> |
| 948 |
<tr> |
| 949 |
<td style="width:58%;padding:3px 8px 3px 8px; font-size:11px; color:<?php echo esc_attr($foldedColor); ?>; text-align:left; white-space:normal; word-break:break-word; overflow-wrap:break-word; vertical-align:top;"> |
| 950 |
<?php echo esc_html($foldedRow['label']); ?> |
| 951 |
</td> |
| 952 |
<td style="width:24%;padding:3px 8px 3px 0; font-size:11px; color:<?php echo esc_attr($foldedColor); ?>; text-align:right; white-space:nowrap; vertical-align:top;"> |
| 953 |
<?php echo esc_html(Helper::toDecimal((int) $foldedRow['base'])); ?> |
| 954 |
</td> |
| 955 |
<td style="width:18%;padding:3px 0 3px; font-size:11px; color:<?php echo esc_attr($foldedColor); ?>; text-align:right; white-space:nowrap; vertical-align:top;"> |
| 956 |
<?php echo esc_html(Helper::toDecimal((int) $foldedRow['tax'])); ?> |
| 957 |
</td> |
| 958 |
</tr> |
| 959 |
<?php endforeach; ?> |
| 960 |
</table> |
| 961 |
</td> |
| 962 |
</tr> |
| 963 |
<?php if ($rcIsReverseCharge): ?> |
| 964 |
<tr> |
| 965 |
<td style="padding:3px 0 4px 8px; font-size:11px; font-weight:600; color:#1e293b; text-align: left;"> |
| 966 |
<?php echo esc_html__('VAT reversed', 'fluent-cart'); ?> |
| 967 |
</td> |
| 968 |
<td style="padding:3px 0 4px; font-size:11px; text-align:right; font-weight:600; color:#1e293b;"> |
| 969 |
<?php echo esc_html($rcReversedValue); ?> |
| 970 |
</td> |
| 971 |
</tr> |
| 972 |
<?php else: ?> |
| 973 |
<tr> |
| 974 |
<td style="padding:4px 0 3px 8px; font-size:11px; font-weight:600; color:#1e293b; border-top:1px solid #e2e8f0; text-align:left;"> |
| 975 |
<?php echo esc_html__('Total tax', 'fluent-cart'); ?> |
| 976 |
</td> |
| 977 |
<td style="padding:4px 0 3px; font-size:11px; font-weight:600; color:#1e293b; border-top:1px solid #e2e8f0; text-align:right;"> |
| 978 |
<?php echo esc_html(Helper::toDecimal((int) $summary['totalOrderTax'])); ?> |
| 979 |
</td> |
| 980 |
</tr> |
| 981 |
<?php if ($includedInPrices > 0): ?> |
| 982 |
<tr> |
| 983 |
<td style="padding:3px 0 3px 8px; font-size:11px; color:#94a3b8; text-align:left;"> |
| 984 |
<?php echo esc_html__('of which included in prices', 'fluent-cart'); ?> |
| 985 |
</td> |
| 986 |
<td style="padding:3px 0 3px; font-size:11px; color:#94a3b8; text-align:right;"> |
| 987 |
<?php echo esc_html(Helper::toDecimal($includedInPrices)); ?> |
| 988 |
</td> |
| 989 |
</tr> |
| 990 |
<?php endif; ?> |
| 991 |
<?php if ($summary['payableTax'] > 0 && $includedInPrices > 0): ?> |
| 992 |
<tr> |
| 993 |
<td style="padding:3px 0 4px 8px; font-size:11px; color:#334155; text-align:left; border-top:1px solid #e2e8f0; padding-top:6px;"> |
| 994 |
<?php echo esc_html__('Payable now (added)', 'fluent-cart'); ?> |
| 995 |
</td> |
| 996 |
<td style="padding:3px 0 4px; font-size:11px; color:#334155; text-align:right; border-top:1px solid #e2e8f0; padding-top:6px;"> |
| 997 |
<?php echo esc_html(Helper::toDecimal((int) $summary['payableTax'])); ?> |
| 998 |
</td> |
| 999 |
</tr> |
| 1000 |
<?php endif; ?> |
| 1001 |
<?php endif; ?> |
| 1002 |
<?php elseif ($rcIsReverseCharge): ?> |
| 1003 |
<?php if ($summary['showRcShippingRow'] && $rcReversedShipping > 0): ?> |
| 1004 |
<tr> |
| 1005 |
<td style="padding:3px 0 3px 8px; font-size:11px; color:#94a3b8;"> |
| 1006 |
<?php echo esc_html__('Added on shipping', 'fluent-cart'); ?> |
| 1007 |
</td> |
| 1008 |
<td style="padding:3px 0 3px; font-size:11px; text-align:right; color:#94a3b8;"> |
| 1009 |
<span style="text-decoration:line-through;opacity:0.6;"><?php echo esc_html(Helper::toDecimal($rcReversedShipping)); ?></span> |
| 1010 |
</td> |
| 1011 |
</tr> |
| 1012 |
<?php endif; ?> |
| 1013 |
<tr> |
| 1014 |
<td style="padding:3px 0 4px 8px; font-size:11px; font-weight:600; color:#1e293b; text-align: left;"> |
| 1015 |
<?php echo esc_html__('Tax reversed', 'fluent-cart'); ?> |
| 1016 |
</td> |
| 1017 |
<td style="padding:3px 0 4px; font-size:11px; text-align:right; font-weight:600; color:#1e293b;"> |
| 1018 |
<?php echo esc_html($rcReversedValue); ?> |
| 1019 |
</td> |
| 1020 |
</tr> |
| 1021 |
<?php else: ?> |
| 1022 |
<?php |
| 1023 |
$rcFeeRows = Arr::get($summary, 'feeTaxLineRows', []); |
| 1024 |
$taxRateLines = Arr::get($summary, 'taxRateLines', []); |
| 1025 |
$productTaxRowCount = !empty($taxRateLines) |
| 1026 |
? count($taxRateLines) |
| 1027 |
: (int) ($summary['inclusiveTax'] > 0) + (int) ($summary['exclusiveTax'] > 0); |
| 1028 |
$rowCount = $productTaxRowCount + count($rcFeeRows) + (int) ($summary['shippingTax'] > 0); |
| 1029 |
$shippingTaxLines = Arr::get($summary, 'shippingTaxLines', []); |
| 1030 |
$shouldShowBreakdown = !empty($taxRateLines) |
| 1031 |
|| !empty($shippingTaxLines) |
| 1032 |
|| $rowCount >= 2 |
| 1033 |
|| ($rowCount === 1 && !($summary['payableTax'] > 0 || $summary['inclusiveTax'] > 0 || (int) Arr::get($summary, 'inclusiveFeeTax', 0) > 0)); |
| 1034 |
?> |
| 1035 |
<?php if (!empty($taxRateLines) && $shouldShowBreakdown): ?> |
| 1036 |
<?php foreach ($taxRateLines as $taxLine): |
| 1037 |
$taxLineColor = !empty($taxLine['inclusive']) ? '#94a3b8' : '#334155'; ?> |
| 1038 |
<tr> |
| 1039 |
<td style="padding:3px 0 3px 8px; font-size:11px; color:<?php echo esc_attr($taxLineColor); ?>; text-align: left;"> |
| 1040 |
<?php echo esc_html($taxLine['label']); ?> |
| 1041 |
</td> |
| 1042 |
<td style="padding:3px 0 3px; font-size:11px; text-align:right; color:<?php echo esc_attr($taxLineColor); ?>;"> |
| 1043 |
<?php echo esc_html(Helper::toDecimal($taxLine['order_tax'])); ?> |
| 1044 |
</td> |
| 1045 |
</tr> |
| 1046 |
<?php endforeach; ?> |
| 1047 |
<?php endif; ?> |
| 1048 |
<?php if (empty($taxRateLines) && $summary['inclusiveTax'] > 0 && $shouldShowBreakdown): ?> |
| 1049 |
<tr> |
| 1050 |
<td style="padding:3px 0 3px 8px; font-size:11px; color:#94a3b8;"> |
| 1051 |
<?php echo esc_html__('Included in item prices', 'fluent-cart'); ?> |
| 1052 |
</td> |
| 1053 |
<td style="padding:3px 0 3px; font-size:11px; text-align:right; color:#94a3b8;"> |
| 1054 |
<?php echo esc_html(Helper::toDecimal($summary['inclusiveTax'])); ?> |
| 1055 |
</td> |
| 1056 |
</tr> |
| 1057 |
<?php endif; ?> |
| 1058 |
<?php if (empty($taxRateLines) && $summary['exclusiveTax'] > 0 && $shouldShowBreakdown): ?> |
| 1059 |
<tr> |
| 1060 |
<td style="padding:3px 0 3px 8px; font-size:11px; color:#334155; text-align: left;"> |
| 1061 |
<?php echo esc_html__('Added on products', 'fluent-cart'); ?> |
| 1062 |
</td> |
| 1063 |
<td style="padding:3px 0 3px; font-size:11px; text-align:right; color:#334155;"> |
| 1064 |
<?php echo esc_html(Helper::toDecimal($summary['exclusiveTax'])); ?> |
| 1065 |
</td> |
| 1066 |
</tr> |
| 1067 |
<?php endif; ?> |
| 1068 |
<?php if ($shouldShowBreakdown) : ?> |
| 1069 |
<?php foreach ($rcFeeRows as $feeRow) : |
| 1070 |
$feeRowColor = $feeRow['inclusive'] ? '#94a3b8' : '#334155'; ?> |
| 1071 |
<tr> |
| 1072 |
<td style="padding:3px 0 3px 8px; font-size:11px; color:<?php echo esc_attr($feeRowColor); ?>; text-align: left;"> |
| 1073 |
<?php echo esc_html($feeRow['display_label']); ?> |
| 1074 |
</td> |
| 1075 |
<td style="padding:3px 0 3px; font-size:11px; text-align:right; color:<?php echo esc_attr($feeRowColor); ?>;"> |
| 1076 |
<?php echo esc_html(Helper::toDecimal($feeRow['tax_amount'])); ?> |
| 1077 |
</td> |
| 1078 |
</tr> |
| 1079 |
<?php endforeach; ?> |
| 1080 |
<?php endif; ?> |
| 1081 |
<?php if ($summary['shippingTax'] > 0 && $shouldShowBreakdown): |
| 1082 |
$isShippingInclusive = (bool) Arr::get($summary, 'isShippingInclusive', false); |
| 1083 |
$shippingRowColor = $isShippingInclusive ? '#94a3b8' : '#334155'; |
| 1084 |
if (!empty($shippingTaxLines)): |
| 1085 |
foreach ($shippingTaxLines as $shLine): ?> |
| 1086 |
<tr> |
| 1087 |
<td style="padding:3px 0 3px 8px; font-size:11px; color:<?php echo esc_attr($shippingRowColor); ?>;"> |
| 1088 |
<?php echo esc_html($shLine['label']); ?> |
| 1089 |
</td> |
| 1090 |
<td style="padding:3px 0 3px; font-size:11px; text-align:right; color:<?php echo esc_attr($shippingRowColor); ?>;"> |
| 1091 |
<?php echo esc_html(Helper::toDecimal($shLine['shipping_tax'])); ?> |
| 1092 |
</td> |
| 1093 |
</tr> |
| 1094 |
<?php endforeach; |
| 1095 |
else: ?> |
| 1096 |
<tr> |
| 1097 |
<td style="padding:3px 0 3px 8px; font-size:11px; color:<?php echo esc_attr($shippingRowColor); ?>;"> |
| 1098 |
<?php echo esc_html($isShippingInclusive ? __('Included in shipping prices', 'fluent-cart') : __('Added on shipping', 'fluent-cart')); ?> |
| 1099 |
</td> |
| 1100 |
<td style="padding:3px 0 3px; font-size:11px; text-align:right; color:<?php echo esc_attr($shippingRowColor); ?>;"> |
| 1101 |
<?php echo esc_html(Helper::toDecimal($summary['shippingTax'])); ?> |
| 1102 |
</td> |
| 1103 |
</tr> |
| 1104 |
<?php endif; ?> |
| 1105 |
<?php endif; ?> |
| 1106 |
<?php if ($summary['payableTax'] > 0): ?> |
| 1107 |
<tr> |
| 1108 |
<td style="padding:4px 0 4px 8px; font-size:11px; font-weight:600; color:#1e293b; |
| 1109 |
border-top:1px solid #e2e8f0; text-align: left;"> |
| 1110 |
<?php echo esc_html__('Total payable tax', 'fluent-cart'); ?> |
| 1111 |
</td> |
| 1112 |
<td style="padding:4px 0 4px; font-size:11px; text-align:right; font-weight:600; color:#1e293b; |
| 1113 |
border-top:1px solid #e2e8f0;"> |
| 1114 |
<?php echo esc_html(Helper::toDecimal($summary['payableTax'])); ?> |
| 1115 |
</td> |
| 1116 |
</tr> |
| 1117 |
<?php endif; ?> |
| 1118 |
<?php if ($summary['inclusiveTax'] > 0 || $summary['inclusiveFeeTax'] > 0): ?> |
| 1119 |
<tr> |
| 1120 |
<td style="padding:3px 0 4px 8px; font-size:11px; color:#94a3b8;"> |
| 1121 |
<?php echo esc_html__('Total tax in this order', 'fluent-cart'); ?> |
| 1122 |
</td> |
| 1123 |
<td style="padding:3px 0 4px; font-size:11px; text-align:right; color:#94a3b8;"> |
| 1124 |
<?php echo esc_html(Helper::toDecimal($summary['totalOrderTax'])); ?> |
| 1125 |
</td> |
| 1126 |
</tr> |
| 1127 |
<?php endif; ?> |
| 1128 |
<?php endif; ?> |
| 1129 |
<?php endif; ?> |
| 1130 |
</table> |
| 1131 |
</td> |
| 1132 |
</tr> |
| 1133 |
</table> |
| 1134 |
</td> |
| 1135 |
</tr> |
| 1136 |
<?php |
| 1137 |
} |
| 1138 |
} |
| 1139 |
|