← All changes
|
app/Services/Renderer/Receipt/ThankYouRender.php
+622
-172
1.3.21
→
1.6.5
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,17 +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 | - | |
| 306 | 382 | <?php $this->renderBundleProducts($item); ?> |
| 307 | 383 | </div> |
| 308 | 384 | <div class="fct-thank-you-page-order-items-list-price"> |
| 309 | 385 | <div class="fct-thank-you-page-order-items-list-price-inner"> |
| @@ -311,9 +387,27 @@ | ||
| 311 | 387 | </div> |
| 312 | 388 | </div> |
| 313 | 389 | </div> |
| 314 | 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> | |
| 315 | 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> | |
| 316 | 410 | <?php endforeach; ?> |
| 317 | 411 | |
| 318 | 412 | <?php $this->renderOrderTotal(); ?> |
| 319 | 413 | |
| @@ -329,9 +423,11 @@ | ||
| 329 | 423 | $order = Arr::get($this->config, 'order', null); |
| 330 | 424 | if (!$order) { |
| 331 | 425 | return; |
| 332 | 426 | } |
| 333 | - $transaction = $order->getLatestTransaction(); | |
| 427 | + $transaction = $order->getLatestTransaction(); | |
| 428 | + $methodSlug = ''; | |
| 429 | + $thankYouPageInstructions = ''; | |
| 334 | 430 | if ($transaction && !empty($transaction->payment_method)) { |
| 335 | 431 | $methodSlug = $transaction->payment_method; |
| 336 | 432 | } |
| 337 | 433 | if (GatewayManager::has($methodSlug)) { |
| @@ -336,9 +432,9 @@ | ||
| 336 | 432 | } |
| 337 | 433 | if (GatewayManager::has($methodSlug)) { |
| 338 | 434 | $gatewayInstance = GatewayManager::getInstance($methodSlug); |
| 339 | 435 | if ($gatewayInstance && isset($gatewayInstance->settings)) { |
| 340 | - $gatewaySettings = (array) $gatewayInstance->settings->get(); | |
| 436 | + $gatewaySettings = (array) $gatewayInstance->settings->get(); | |
| 341 | 437 | $thankYouPageInstructions = Arr::get($gatewaySettings, 'thank_you_page_instructions', ''); |
| 342 | 438 | } |
| 343 | 439 | } |
| 344 | 440 | |
| @@ -359,11 +455,11 @@ | ||
| 359 | 455 | <?php $this->renderSubtotal(); ?> |
| 360 | 456 | <?php $this->renderDiscount(); ?> |
| 361 | 457 | <?php $this->renderShipping(); ?> |
| 362 | 458 | <?php $this->renderFees(); ?> |
| 363 | - <?php $this->renderTaxTotal(); ?> | |
| 364 | - <?php $this->renderShippingTax(); ?> | |
| 459 | + <?php $this->renderTaxSummaryBox(); ?> | |
| 365 | 460 | |
| 461 | + <?php $this->renderProrateCredit(); ?> | |
| 366 | 462 | <?php $this->renderRefund(); ?> |
| 367 | 463 | <?php $this->renderTotal(); ?> |
| 368 | 464 | <?php $this->renderPaymentMethod(); ?> |
| 369 | 465 | </div> |
| @@ -372,12 +468,11 @@ | ||
| 372 | 468 | |
| 373 | 469 | public function renderTaxNote() |
| 374 | 470 | { |
| 375 | 471 | $order = Arr::get($this->config, 'order', null); |
| 376 | - $taxtotal = $order->tax_total + $order->shipping_tax; | |
| 377 | - if (Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.valid') && !$taxtotal): ?> | |
| 472 | + if ($order->isReverseChargeTaxOrder()): ?> | |
| 378 | 473 | <div style="text-align: right; font-size: 14px; margin-top: 10px;"> |
| 379 | - <?php echo '*' . esc_html__('Tax to be paid on reverse charge basis', 'fluent-cart') ?> | |
| 474 | + <?php echo '*' . esc_html(TaxModule::getReverseChargeNoticeText()) ?> | |
| 380 | 475 | </div> |
| 381 | 476 | <?php |
| 382 | 477 | endif; |
| 383 | 478 | } |
| @@ -397,33 +492,77 @@ | ||
| 397 | 492 | |
| 398 | 493 | public function renderDiscount() |
| 399 | 494 | { |
| 400 | 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; | |
| 401 | 501 | |
| 402 | 502 | if ($order->manual_discount_total + $order->coupon_discount_total > 0): ?> |
| 403 | - <div class="fct-meta-line fct-thank-you-page-order-items-total-discount"> | |
| 404 | - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label"> | |
| 405 | - <?php echo esc_html__('Discount', 'fluent-cart'); ?> | |
| 406 | - </div> | |
| 407 | - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value"> | |
| 408 | - - <?php echo esc_html(Helper::toDecimal($order->manual_discount_total + $order->coupon_discount_total)); ?> | |
| 409 | - </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'); ?> | |
| 410 | 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: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: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: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:rgb(107,114,128);"> | |
| 527 | + <?php echo esc_html(Helper::toDecimal($prorateCredit)); ?> | |
| 528 | + </div> | |
| 529 | + </div> | |
| 530 | + <?php endif; ?> | |
| 411 | 531 | <?php endif; |
| 412 | 532 | } |
| 413 | 533 | |
| 534 | + public function renderProrateCredit() | |
| 535 | + { | |
| 536 | + // Rendered as a sub-row inside renderDiscount. | |
| 537 | + } | |
| 538 | + | |
| 414 | 539 | public function renderShipping() |
| 415 | 540 | { |
| 416 | 541 | $order = Arr::get($this->config, 'order', null); |
| 417 | 542 | |
| 418 | - if ($order->shipping_total > 0): ?> | |
| 419 | - <div class="fct-meta-line fct-thank-you-page-order-items-total-shipping"> | |
| 420 | - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label"> | |
| 421 | - <?php echo esc_html__('Shipping', 'fluent-cart'); ?> | |
| 422 | - </div> | |
| 423 | - <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; ?> | |
| 424 | 561 | </div> |
| 425 | - <?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 | |
| 426 | 565 | } |
| 427 | 566 | |
| 428 | 567 | public function renderFees() |
| 429 | 568 | { |
| @@ -443,42 +582,8 @@ | ||
| 443 | 582 | </div> |
| 444 | 583 | <?php endforeach; |
| 445 | 584 | } |
| 446 | 585 | |
| 447 | - public function renderTaxTotal() | |
| 448 | - { | |
| 449 | - $order = Arr::get($this->config, 'order', null); | |
| 450 | - | |
| 451 | - if ($order->tax_total > 0): ?> | |
| 452 | - <div class="fct-meta-line fct-thank-you-page-order-items-total-tax"> | |
| 453 | - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label"> | |
| 454 | - <?php echo esc_html__('Total Tax', 'fluent-cart'); ?> | |
| 455 | - <?php echo $order->tax_behavior == 2 ? esc_html__('(Included)', 'fluent-cart') : esc_html__('(Excluded)', 'fluent-cart'); ?> | |
| 456 | - </div> | |
| 457 | - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value"> | |
| 458 | - <?php echo esc_html(Helper::toDecimal($order->tax_total)); ?> | |
| 459 | - </div> | |
| 460 | - </div> | |
| 461 | - <?php endif; | |
| 462 | - } | |
| 463 | - | |
| 464 | - public function renderShippingTax() | |
| 465 | - { | |
| 466 | - $order = Arr::get($this->config, 'order', null); | |
| 467 | - | |
| 468 | - if ($order->shipping_tax > 0): ?> | |
| 469 | - <div class="fct-meta-line fct-thank-you-page-order-items-total-shipping-tax"> | |
| 470 | - <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label"> | |
| 471 | - <?php echo esc_html__('Shipping Tax', 'fluent-cart'); ?> | |
| 472 | - <?php echo $order->tax_behavior == 2 ? esc_html__('(Included)', 'fluent-cart') : esc_html__('(Excluded)', 'fluent-cart'); ?> | |
| 473 | - </div> | |
| 474 | - <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value"> | |
| 475 | - <?php echo esc_html(Helper::toDecimal($order->shipping_tax)); ?> | |
| 476 | - </div> | |
| 477 | - </div> | |
| 478 | - <?php endif; | |
| 479 | - } | |
| 480 | - | |
| 481 | 586 | public function renderRefund() |
| 482 | 587 | { |
| 483 | 588 | $order = Arr::get($this->config, 'order', null); |
| 484 | 589 | |
| @@ -496,8 +601,15 @@ | ||
| 496 | 601 | |
| 497 | 602 | public function renderTotal() |
| 498 | 603 | { |
| 499 | 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 | + } | |
| 500 | 612 | ?> |
| 501 | 613 | <div class="fct-meta-line fct-thank-you-page-order-items-total-total"> |
| 502 | 614 | <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label"> |
| 503 | 615 | <?php echo esc_html__('Total', 'fluent-cart'); ?> |
| @@ -502,9 +614,9 @@ | ||
| 502 | 614 | <div class="fct-meta-line-label fct-thank-you-page-order-items-total-label"> |
| 503 | 615 | <?php echo esc_html__('Total', 'fluent-cart'); ?> |
| 504 | 616 | </div> |
| 505 | 617 | <div class="fct-meta-line-value fct-thank-you-page-order-items-total-value"> |
| 506 | - <?php echo esc_html(Helper::toDecimal($order->total_amount - $order->total_refund)); ?> | |
| 618 | + <?php echo esc_html(Helper::toDecimal($displayTotal)); ?> | |
| 507 | 619 | </div> |
| 508 | 620 | </div> |
| 509 | 621 | <?php |
| 510 | 622 | } |
| @@ -551,9 +663,9 @@ | ||
| 551 | 663 | <?php foreach ($subscriptions as $subs): ?> |
| 552 | 664 | <tr> |
| 553 | 665 | <td class="fct-thank-you-page-order-items-subscriptions-table-file"> |
| 554 | 666 | <p> |
| 555 | - <?php echo esc_html($subs->item_name); ?> | |
| 667 | + <?php echo esc_html($subs->display_item_name); ?> | |
| 556 | 668 | </p> |
| 557 | 669 | </td> |
| 558 | 670 | |
| 559 | 671 | <td class="fct-thank-you-page-order-items-subscriptions-billing-infos"> |
| @@ -566,12 +678,12 @@ | ||
| 566 | 678 | |
| 567 | 679 | <?php if (!empty($subs->next_billing_date)) : ?> |
| 568 | 680 | <p class="fct-thank-you-page-order-items-subscriptions-billing-infos-next-billing"><?php |
| 569 | 681 | echo sprintf( |
| 570 | - /* translators: 1: Next billing date */ | |
| 682 | + /* translators: 1: Next billing date */ | |
| 571 | 683 | esc_html__('- Auto renews on %1$s', 'fluent-cart'), |
| 572 | 684 | esc_html( |
| 573 | - \FluentCart\App\Services\DateTime\DateTime::anyTimeToGmt($subs->next_billing_date)->format('M d, Y h:i A') | |
| 685 | + \FluentCart\App\Services\DateTime\DateFormatter::format($subs->next_billing_date, true, $order) | |
| 574 | 686 | ) |
| 575 | 687 | ); |
| 576 | 688 | ?> |
| 577 | 689 | </p> |
| @@ -616,9 +728,9 @@ | ||
| 616 | 728 | <tr> |
| 617 | 729 | <td> |
| 618 | 730 | <?php if ($downloadItem['downloads']): ?> |
| 619 | 731 | |
| 620 | - <table role="presentation"> | |
| 732 | + <table role="presentation" width="100%"> | |
| 621 | 733 | <tbody> |
| 622 | 734 | <?php foreach ($downloadItem['downloads'] as $download): ?> |
| 623 | 735 | <tr> |
| 624 | 736 | <td class="fct-thank-you-page-order-items-downloads-table-file"> |
| @@ -661,13 +773,13 @@ | ||
| 661 | 773 | { |
| 662 | 774 | $showNotice = $show_notice ?? true; |
| 663 | 775 | ?> |
| 664 | 776 | <?php if (!$showNotice) { |
| 665 | - return; | |
| 666 | - } ?> | |
| 777 | + return; | |
| 778 | + } ?> | |
| 667 | 779 | <table |
| 668 | - class="fct-thank-you-page-order-items-downloads-notice" | |
| 669 | - role="presentation"> | |
| 780 | + class="fct-thank-you-page-order-items-downloads-notice" | |
| 781 | + role="presentation"> | |
| 670 | 782 | <tbody> |
| 671 | 783 | <tr> |
| 672 | 784 | <td> |
| 673 | 785 | <p class="fct-thank-you-page-order-items-downloads-notice-title"> |
| @@ -688,13 +800,13 @@ | ||
| 688 | 800 | { |
| 689 | 801 | $showNotice = $show_notice ?? true; |
| 690 | 802 | ?> |
| 691 | 803 | <?php if (!$showNotice) { |
| 692 | - return; | |
| 693 | - } ?> | |
| 804 | + return; | |
| 805 | + } ?> | |
| 694 | 806 | <table |
| 695 | - class="fct-thank-you-page-order-items-downloads-notice" | |
| 696 | - role="presentation"> | |
| 807 | + class="fct-thank-you-page-order-items-downloads-notice" | |
| 808 | + role="presentation"> | |
| 697 | 809 | <tbody> |
| 698 | 810 | <tr> |
| 699 | 811 | <td> |
| 700 | 812 | <p class="fct-thank-you-page-order-items-downloads-notice-title"> |
| @@ -753,14 +865,16 @@ | ||
| 753 | 865 | |
| 754 | 866 | public function renderAddress() |
| 755 | 867 | { |
| 756 | 868 | $order = Arr::get($this->config, 'order', null); |
| 757 | - if ($order->fulfillment_type === 'physical') : ?> | |
| 758 | - <div class="fct-thank-you-page-order-items-addresses"> | |
| 759 | - <?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') : ?> | |
| 760 | 873 | <?php $this->renderShipToAddress(); ?> |
| 761 | - </div> | |
| 762 | - <?php endif; | |
| 874 | + <?php endif; ?> | |
| 875 | + </div> | |
| 876 | + <?php | |
| 763 | 877 | } |
| 764 | 878 | |
| 765 | 879 | public function renderBillToAddress() |
| 766 | 880 | { |
| @@ -795,26 +909,52 @@ | ||
| 795 | 909 | <div class="fct-thank-you-page-order-items-addresses-bill-to-phone"> |
| 796 | 910 | <?php echo esc_html($phoneNumber); ?> |
| 797 | 911 | </div> |
| 798 | 912 | <?php endif; ?> |
| 799 | - <div class="fct-thank-you-page-order-items-addresses-bill-to-company-name"> | |
| 800 | - <?php | |
| 801 | - $companyName = Arr::get($order->billing_address->meta ?? [], 'other_data.company_name', ''); | |
| 802 | - | |
| 803 | - if ($companyName === '') { | |
| 804 | - $companyName = Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.name', ''); | |
| 805 | - } | |
| 806 | - 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 !== ''): | |
| 807 | 921 | ?> |
| 808 | - </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; ?> | |
| 809 | 939 | <div class="fct-thank-you-page-order-items-addresses-bill-to-vat-number"> |
| 810 | 940 | <?php |
| 811 | - $vatNumber = Arr::get($orderTaxRates->meta ?? [], 'vat_reverse.vat_number', ''); | |
| 941 | + $vatNumber = $order->getCustomerTaxNumber(); | |
| 812 | 942 | if ($vatNumber !== '') { |
| 813 | - 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); | |
| 814 | 945 | } |
| 815 | 946 | ?> |
| 816 | 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; ?> | |
| 817 | 957 | </div> |
| 818 | 958 | <?php |
| 819 | 959 | } |
| 820 | 960 | |
| @@ -868,10 +1008,10 @@ | ||
| 868 | 1008 | $profilePage = $this->settings->getCustomerProfilePage(); |
| 869 | 1009 | |
| 870 | 1010 | ?> |
| 871 | 1011 | <a |
| 872 | - class="fct-thank-you-page-view-order-button" | |
| 873 | - 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); ?>"> | |
| 874 | 1014 | <?php echo esc_html__('View Order', 'fluent-cart'); ?> |
| 875 | 1015 | </a> |
| 876 | 1016 | <?php |
| 877 | 1017 | } |
| @@ -880,17 +1020,17 @@ | ||
| 880 | 1020 | { |
| 881 | 1021 | $order = Arr::get($this->config, 'order', null); |
| 882 | 1022 | ?> |
| 883 | 1023 | <a |
| 884 | - class="fct-thank-you-page-download-receipt-button" | |
| 885 | - href="<?php echo esc_url(\FluentCart\App\Services\URL::appendQueryParams( | |
| 886 | - home_url(), | |
| 887 | - [ | |
| 888 | - 'fluent-cart' => 'receipt', | |
| 889 | - 'order_hash' => $order->uuid, | |
| 890 | - 'download' => 1 | |
| 891 | - ] | |
| 892 | - )) ?>"> | |
| 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 | + )) ?>"> | |
| 893 | 1033 | <?php echo esc_html__('Download Receipt', 'fluent-cart'); ?> |
| 894 | 1034 | </a> |
| 895 | 1035 | <?php |
| 896 | 1036 | } |
| @@ -948,35 +1088,35 @@ | ||
| 948 | 1088 | } |
| 949 | 1089 | |
| 950 | 1090 | $total = count($item['bundle_items']); |
| 951 | 1091 | ?> |
| 952 | - <div class="fct-bundle-products" data-fluent-cart-collapsibles> | |
| 953 | - <h4 class="fct-bundle-products-title"> | |
| 954 | - <?php echo esc_html__('Bundle of', 'fluent-cart') . ':'; ?> | |
| 955 | - </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> | |
| 956 | 1096 | |
| 957 | - <div class="fct-bundle-products-list"> | |
| 958 | - <?php foreach (array_slice($item['bundle_items'], 0, 2) as $bundleItem): ?> | |
| 959 | - <p> | |
| 960 | - <?php echo esc_html(Arr::get($bundleItem, 'title', '')); ?> | |
| 961 | - </p> | |
| 962 | - <?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; ?> | |
| 963 | 1103 | |
| 964 | - <?php if ($total > 2): ?> | |
| 965 | - <div class="fct-bundle-products-more"> | |
| 966 | - <div class="fct-bundle-products-more-list"> | |
| 967 | - <?php foreach (array_slice($item['bundle_items'], 2) as $bundleItem): ?> | |
| 968 | - <p> | |
| 969 | - <?php echo esc_html(Arr::get($bundleItem, 'title', '')); ?> | |
| 970 | - </p> | |
| 971 | - <?php endforeach; ?> | |
| 972 | - </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; ?> | |
| 973 | 1112 | </div> |
| 974 | - <?php endif; ?> | |
| 975 | - </div> | |
| 1113 | + </div> | |
| 1114 | + <?php endif; ?> | |
| 1115 | + </div> | |
| 976 | 1116 | |
| 977 | - <?php if ($total > 2) : ?> | |
| 978 | - <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> | |
| 979 | 1119 | <span class="see-more-text"> |
| 980 | 1120 | <?php echo esc_html__('See More', 'fluent-cart'); ?> |
| 981 | 1121 | <svg xmlns="http://www.w3.org/2000/svg" width="12" height="7" viewBox="0 0 12 7" fill="none"> |
| 982 | 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"/> |
| @@ -982,17 +1122,327 @@ | ||
| 982 | 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"/> |
| 983 | 1123 | </svg> |
| 984 | 1124 | </span> |
| 985 | 1125 | |
| 986 | - <span class="see-less-text"> | |
| 1126 | + <span class="see-less-text"> | |
| 987 | 1127 | <?php echo esc_html__('See Less', 'fluent-cart'); ?> |
| 988 | 1128 | <svg xmlns="http://www.w3.org/2000/svg" width="12" height="7" viewBox="0 0 14 8" fill="none"> |
| 989 | 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"/> |
| 990 | 1130 | </svg> |
| 991 | 1131 | </span> |
| 992 | - </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'); ?> ▾</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; ?> | |
| 993 | 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> | |
| 994 | 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> | |
| 995 | 1445 | <?php |
| 996 | 1446 | } |
| 997 | 1447 | |
| 998 | 1448 | } |