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/Http/Controllers/FrontendControllers/CustomerOrderController.php +27 -4 1.6.3 → 1.7.0 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,36 @@
239 238 $variationIds[] = $item->object_id;
240 239 $productIds[] = $item->post_id;
241 240 }
242 241
242 +
243 + $upgradableVariationIds = [];
244 + $isUpgradeEligibleOrder = in_array($order->payment_status, [
245 + Status::PAYMENT_PAID,
246 + Status::PAYMENT_PARTIALLY_PAID,
247 + Status::PAYMENT_PARTIALLY_REFUNDED
248 + ]);
249 +
250 + if ($isUpgradeEligibleOrder && $variationIds) {
251 + $upgradableVariationIds = Meta::query()
252 + ->where('meta_key', 'variant_upgrade_path')
253 + ->where('object_type', 'variant_upgrade')
254 + ->whereIn('object_id', $variationIds)
255 + ->pluck('object_id')
256 + ->toArray();
257 + }
258 +
259 + foreach ($orderItems as &$orderItem) {
260 + $orderItem['has_upgrade_paths'] = Arr::get($orderItem, 'payment_type') === 'onetime'
261 + && !Arr::get($orderItem, 'line_meta.parent_item_id')
262 + && in_array(Arr::get($orderItem, 'variation_id'), $upgradableVariationIds);
263 + }
264 + unset($orderItem);
265 +
243 266 $formattedOrderData = [
244 267 'fulfillment_type' => $order->fulfillment_type,
245 268 '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'),
269 + 'created_at' => $order->created_at->format('Y-m-d H:i:s'),
247 270 'invoice_no' => $order->invoice_no,
248 271 'currency' => $order->currency,
249 272 'uuid' => $order->uuid,
250 273 'order_items' => $orderItems,
@@ -279,9 +302,9 @@
279 302 ];
280 303
281 304 $formattedOrderData['subscriptions'] = $order->subscriptions
282 305 ->filter(function ($subscription) {
283 - return !in_array($subscription->status, [Status::SUBSCRIPTION_PENDING, Status::SUBSCRIPTION_INTENDED]);
306 + return $subscription->isVisibleToCustomer();
284 307 })
285 308 ->map(function ($subscription) {
286 309 return OrderService::transformSubscription($subscription);
287 310 });