PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.0
1.7.0 1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 All 50 releases
← All changes | app/Services/ShortCodeParser/Parsers/OrderParser.php +75 -21 1.5.2 → 1.7.0 View file →
@@ -9,8 +9,9 @@
9 9 use FluentCart\App\Models\Order;
10 10 use FluentCart\App\Models\Subscription;
11 11 use FluentCart\App\Modules\PaymentMethods\Core\GatewayManager;
12 12 use FluentCart\App\Services\DateTime\DateTime;
13 +use FluentCart\App\Services\DateTime\DateFormatter;
13 14 use FluentCart\App\Services\Payments\PaymentHelper;
14 15 use FluentCart\App\Services\Payments\PaymentReceipt;
15 16 use FluentCart\App\Services\TemplateService;
16 17 use FluentCart\App\Services\Renderer\Receipt\TaxSummaryHelper;
@@ -54,8 +55,9 @@
54 55 // ];
55 56
56 57 protected array $methodMap = [
57 58 'item_count' => 'getItemCount',
59 + 'review_url' => 'getReviewUrl',
58 60 'is_digital' => 'getIsDigital',
59 61 'store_vat_display' => 'getStoreVatDisplay',
60 62 'store_company_name' => 'getStoreCompanyName',
61 63 'store_company_display' => 'getStoreCompanyDisplay',
@@ -104,14 +106,12 @@
104 106 if (in_array($accessor, ['updated_at', 'created_at'])) {
105 107 $date = Arr::get($this->data, $this->attributeMap[$accessor]);
106 108 $timestamp = DateTime::anyTimeToGmt($date)->getTimestamp();
107 109
108 - $date = wp_date(
109 - get_option('date_format'),
110 - $timestamp,
111 - new \DateTimeZone($this->orderTz)
112 - );
113 -
110 + // Through DateFormatter so the store's format and timezone settings
111 + // reach this too; orderTz is only consulted on the Browser source.
112 + $date = DateFormatter::format($timestamp, false, $this->orderTz);
113 +
114 114 return Helper::translateNumber($date);
115 115 }
116 116
117 117 // Handle _formatted suffix for cent columns (e.g. total_amount_formatted)
@@ -361,8 +361,38 @@
361 361
362 362 return is_user_logged_in() ? $orderLink : wp_login_url($orderLink);
363 363 }
364 364
365 + /**
366 + * The public "review your order" page for this order.
367 + *
368 + * Carries the order uuid, which is what lets the link work for a
369 + * guest-checkout buyer with no account to sign into — so, unlike
370 + * getCustomerOrderLink(), it is never wrapped in wp_login_url().
371 + *
372 + * Drop {{order.review_url}} into any order email template to invite a
373 + * review. Best paired with a notification that fires after fulfilment;
374 + * the page only resolves once the order has actually completed.
375 + */
376 + public function getReviewUrl($accessor = null, $code = null)
377 + {
378 + $orderHash = (string) Arr::get($this->order, 'uuid', '');
379 +
380 + if ($orderHash !== '') {
381 + return Order::reviewUrlForHash($orderHash);
382 + }
383 +
384 + $orderId = Arr::get($this->order, 'id');
385 +
386 + if (empty($orderId)) {
387 + return $code;
388 + }
389 +
390 + $order = Order::query()->find($orderId);
391 +
392 + return $order instanceof Order ? $order->getOrderReviewUrl() : $code;
393 + }
394 +
365 395 public function getPaymentLink($accessor = null, $code = null)
366 396 {
367 397 if (empty($this->order)) {
368 398 return $code;
@@ -549,24 +579,14 @@
549 579 $valueStyle = 'text-align:right;';
550 580
551 581 $rows = '';
552 582
553 - if ($summary['isReverseCharge']) {
554 - $rcReversedTotal = isset($summary['reversedTaxTotal']) ? (int) $summary['reversedTaxTotal'] : 0;
555 - $rcReversedValue = $rcReversedTotal > 0
556 - ? esc_html(Helper::toDecimal($rcReversedTotal))
557 - : esc_html__('Charge reversed', 'fluent-cart');
558 - $rows .= '<tr><td colspan="2" style="' . $headingStyle . '">'
559 - . esc_html__('TAX SUMMARY', 'fluent-cart')
560 - . '</td></tr>';
561 - $rows .= '<tr>'
562 - . '<td style="' . $totalStyle . '">' . esc_html__('Tax reversed', 'fluent-cart') . '</td>'
563 - . '<td style="' . $totalStyle . $valueStyle . '">' . $rcReversedValue . '</td>'
564 - . '</tr>';
565 - return $this->wrapTaxBreakdownBox($rows);
566 - }
567 -
568 583 $foldedRateLines = Arr::get($summary, 'foldedRateLines', []);
584 + $isRcOrder = !empty($summary['isReverseCharge']);
585 + $rcReversedTotal = isset($summary['reversedTaxTotal']) ? (int) $summary['reversedTaxTotal'] : 0;
586 + $rcReversedValue = $rcReversedTotal > 0
587 + ? esc_html(Helper::toDecimal($rcReversedTotal))
588 + : esc_html__('Charge reversed', 'fluent-cart');
569 589 $includedInPrices = (int) Arr::get($summary, 'includedInPrices', 0);
570 590 $opFeeRows = Arr::get($summary, 'feeTaxLineRows', []);
571 591 $taxRateLines = Arr::get($summary, 'taxRateLines', []);
572 592 $productTaxRowCount = !empty($taxRateLines)
@@ -578,8 +598,20 @@
578 598 || !empty($shippingTaxLines)
579 599 || $rowCount >= 2
580 600 || ($rowCount === 1 && !($summary['payableTax'] > 0 || $summary['inclusiveTax'] > 0 || (int) Arr::get($summary, 'inclusiveFeeTax', 0) > 0));
581 601
602 + $isSimplifiedMode = ($summary['displayMode'] ?? '') === 'simplified';
603 +
604 + if ($isSimplifiedMode && !empty($summary['simpleLine'])) {
605 + $rows .= '<tr>'
606 + . '<td style="' . $normalStyle . '">' . esc_html((string) $summary['simpleLine']['label']) . '</td>'
607 + . '<td style="' . $normalStyle . $valueStyle . '">' . esc_html((string) $summary['simpleLine']['value']) . '</td>'
608 + . '</tr>';
609 +
610 + // Simplified mode: single tax line only, skip the detailed breakdown below.
611 + return $this->wrapTaxBreakdownBox($rows);
612 + }
613 +
582 614 if (!empty($foldedRateLines)) {
583 615 $colHeadStyle = 'width:58%;padding:3px 8px 3px 0;font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:0.06em;color:#64748b;vertical-align:top;';
584 616 $colHeadBaseStyle = '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;';
585 617 $colHeadTaxStyle = 'width:18%;padding: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;';
@@ -607,8 +639,19 @@
607 639 $nestedTable .= '</table>';
608 640
609 641 $rows .= '<tr><td colspan="2" style="padding:2px 0 0 0;">' . $nestedTable . '</td></tr>';
610 642
643 + if ($isRcOrder) {
644 + $rcReversedTotalValue = $rcReversedTotal > 0
645 + ? CurrencySettings::getPriceHtml($rcReversedTotal, $currency)
646 + : esc_html__('Charge reversed', 'fluent-cart');
647 + $rows .= '<tr>'
648 + . '<td style="' . $totalStyle . '">' . esc_html__('VAT reversed', 'fluent-cart') . '</td>'
649 + . '<td style="' . $totalStyle . $valueStyle . '">' . $rcReversedTotalValue . '</td>'
650 + . '</tr>';
651 + return $this->wrapTaxBreakdownBox($rows);
652 + }
653 +
611 654 $rows .= '<tr>'
612 655 . '<td style="' . $totalStyle . '">' . esc_html__('Total tax', 'fluent-cart') . '</td>'
613 656 . '<td style="' . $totalStyle . $valueStyle . '">' . CurrencySettings::getPriceHtml((int) $summary['totalOrderTax'], $currency) . '</td>'
614 657 . '</tr>';
@@ -627,8 +670,19 @@
627 670 . '<td style="' . $payableStyle . $valueStyle . '">' . CurrencySettings::getPriceHtml((int) $summary['payableTax'], $currency) . '</td>'
628 671 . '</tr>';
629 672 }
630 673
674 + return $this->wrapTaxBreakdownBox($rows);
675 + }
676 +
677 + if ($isRcOrder) {
678 + $rows .= '<tr><td colspan="2" style="' . $headingStyle . '">'
679 + . esc_html__('TAX SUMMARY', 'fluent-cart')
680 + . '</td></tr>';
681 + $rows .= '<tr>'
682 + . '<td style="' . $totalStyle . '">' . esc_html__('Tax reversed', 'fluent-cart') . '</td>'
683 + . '<td style="' . $totalStyle . $valueStyle . '">' . $rcReversedValue . '</td>'
684 + . '</tr>';
631 685 return $this->wrapTaxBreakdownBox($rows);
632 686 }
633 687
634 688 $rows .= '<tr><td colspan="2" style="' . $headingStyle . '">'