← All changes
|
app/Http/Controllers/FrontendControllers/CustomerOrderController.php
+25
-3
1.6.3
→
1.6.5
View file →
| @@ -29,9 +29,8 @@ | ||
| 29 | 29 | use FluentCart\App\Services\Renderer\Receipt\TaxSummaryHelper; |
| 30 | 30 | use FluentCart\Framework\Database\Orm\Builder; |
| 31 | 31 | use FluentCart\Framework\Database\Orm\Relations\HasMany; |
| 32 | 32 | use FluentCart\Framework\Http\Request\Request; |
| 33 | -use FluentCart\App\Services\DateTime\DateTime; | |
| 34 | 33 | use FluentCart\Framework\Support\Arr; |
| 35 | 34 | use FluentCart\Framework\Support\Collection; |
| 36 | 35 | use FluentCart\Framework\Validator\Validator; |
| 37 | 36 | use FluentCartPro\App\Modules\Licensing\Models\License; |
| @@ -82,9 +81,9 @@ | ||
| 82 | 81 | ->paginate($perPage, ['*'], 'page', $page); |
| 83 | 82 | |
| 84 | 83 | $orders->transform(function ($order) { |
| 85 | 84 | return [ |
| 86 | - 'created_at' => DateTime::gmtToTimezone($order->created_at, Arr::get($order->config, 'user_tz', wp_timezone_string()))->format('Y-m-d H:i:s'), | |
| 85 | + 'created_at' => $order->created_at->format('Y-m-d H:i:s'), | |
| 87 | 86 | 'invoice_no' => $order->invoice_no, |
| 88 | 87 | 'total_amount' => $order->total_amount, |
| 89 | 88 | 'currency' => $order->currency, |
| 90 | 89 | 'uuid' => $order->uuid, |
| @@ -239,12 +238,35 @@ | ||
| 239 | 238 | $variationIds[] = $item->object_id; |
| 240 | 239 | $productIds[] = $item->post_id; |
| 241 | 240 | } |
| 242 | 241 | |
| 242 | + $upgradableVariationIds = []; | |
| 243 | + $isUpgradeEligibleOrder = in_array($order->payment_status, [ | |
| 244 | + Status::PAYMENT_PAID, | |
| 245 | + Status::PAYMENT_PARTIALLY_PAID, | |
| 246 | + Status::PAYMENT_PARTIALLY_REFUNDED | |
| 247 | + ]); | |
| 248 | + | |
| 249 | + if ($isUpgradeEligibleOrder && $variationIds) { | |
| 250 | + $upgradableVariationIds = Meta::query() | |
| 251 | + ->where('meta_key', 'variant_upgrade_path') | |
| 252 | + ->where('object_type', 'variant_upgrade') | |
| 253 | + ->whereIn('object_id', $variationIds) | |
| 254 | + ->pluck('object_id') | |
| 255 | + ->toArray(); | |
| 256 | + } | |
| 257 | + | |
| 258 | + foreach ($orderItems as &$orderItem) { | |
| 259 | + $orderItem['has_upgrade_paths'] = Arr::get($orderItem, 'payment_type') === 'onetime' | |
| 260 | + && !Arr::get($orderItem, 'line_meta.parent_item_id') | |
| 261 | + && in_array(Arr::get($orderItem, 'variation_id'), $upgradableVariationIds); | |
| 262 | + } | |
| 263 | + unset($orderItem); | |
| 264 | + | |
| 243 | 265 | $formattedOrderData = [ |
| 244 | 266 | 'fulfillment_type' => $order->fulfillment_type, |
| 245 | 267 | 'type' => $order->type, |
| 246 | - 'created_at' => DateTime::gmtToTimezone($order->created_at, Arr::get($order->config, 'user_tz', wp_timezone_string()))->format('Y-m-d H:i:s'), | |
| 268 | + 'created_at' => $order->created_at->format('Y-m-d H:i:s'), | |
| 247 | 269 | 'invoice_no' => $order->invoice_no, |
| 248 | 270 | 'currency' => $order->currency, |
| 249 | 271 | 'uuid' => $order->uuid, |
| 250 | 272 | 'order_items' => $orderItems, |