← All changes
|
app/Services/ShortCodeParser/Parsers/OrderParser.php
+36
-6
1.6.3
→
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) |
| @@ -359,8 +359,38 @@ | ||
| 359 | 359 | |
| 360 | 360 | $orderLink = TemplateService::getCustomerProfileUrl('order/' . Arr::get($this->order, 'uuid')); |
| 361 | 361 | |
| 362 | 362 | return is_user_logged_in() ? $orderLink : wp_login_url($orderLink); |
| 363 | + } | |
| 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; | |
| 363 | 393 | } |
| 364 | 394 | |
| 365 | 395 | public function getPaymentLink($accessor = null, $code = null) |
| 366 | 396 | { |