← All changes
|
app/Services/ShortCodeParser/Parsers/OrderParser.php
+31
-0
1.6.5
→
1.7.0
View file →
| @@ -55,8 +55,9 @@ | ||
| 55 | 55 | // ]; |
| 56 | 56 | |
| 57 | 57 | protected array $methodMap = [ |
| 58 | 58 | 'item_count' => 'getItemCount', |
| 59 | + 'review_url' => 'getReviewUrl', | |
| 59 | 60 | 'is_digital' => 'getIsDigital', |
| 60 | 61 | 'store_vat_display' => 'getStoreVatDisplay', |
| 61 | 62 | 'store_company_name' => 'getStoreCompanyName', |
| 62 | 63 | 'store_company_display' => 'getStoreCompanyDisplay', |
| @@ -358,8 +359,38 @@ | ||
| 358 | 359 | |
| 359 | 360 | $orderLink = TemplateService::getCustomerProfileUrl('order/' . Arr::get($this->order, 'uuid')); |
| 360 | 361 | |
| 361 | 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; | |
| 362 | 393 | } |
| 363 | 394 | |
| 364 | 395 | public function getPaymentLink($accessor = null, $code = null) |
| 365 | 396 | { |