PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
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 1.3.19 All 49 releases
← All changes | app/Http/Controllers/FrontendControllers/CustomerOrderController.php +59 -15 1.4.1 → 1.6.5 View file →
@@ -20,8 +20,9 @@
20 20 use FluentCart\App\Models\OrderTransaction;
21 21 use FluentCart\App\Models\ProductDownload;
22 22 use FluentCart\App\Models\ProductVariation;
23 23 use FluentCart\App\Models\Subscription;
24 +use FluentCart\App\Modules\Subscriptions\Services\SystemChargeService;
24 25 use FluentCart\App\Services\FileSystem\FileManager;
25 26 use FluentCart\App\Services\Localization\LocalizationManager;
26 27 use FluentCart\App\Services\OrderService;
27 28 use FluentCart\App\Services\Payments\PaymentHelper;
@@ -28,9 +29,8 @@
28 29 use FluentCart\App\Services\Renderer\Receipt\TaxSummaryHelper;
29 30 use FluentCart\Framework\Database\Orm\Builder;
30 31 use FluentCart\Framework\Database\Orm\Relations\HasMany;
31 32 use FluentCart\Framework\Http\Request\Request;
32 -use FluentCart\App\Services\DateTime\DateTime;
33 33 use FluentCart\Framework\Support\Arr;
34 34 use FluentCart\Framework\Support\Collection;
35 35 use FluentCart\Framework\Validator\Validator;
36 36 use FluentCartPro\App\Modules\Licensing\Models\License;
@@ -62,11 +62,11 @@
62 62 $page = (int)$request->get('page', 1);
63 63 $search = $request->getSafe('search', 'sanitize_text_field');
64 64
65 65 $orders = Order::query()
66 - ->select(['invoice_no', 'id', 'parent_id', 'total_amount', 'fee_total', 'uuid', 'type', 'status', 'created_at'])
66 + ->select(['invoice_no', 'id', 'parent_id', 'total_amount', 'fee_total', 'currency', 'uuid', 'type', 'status', 'created_at'])
67 67 ->with(['order_items' => function ($query) {
68 - $query->select('id', 'order_id', 'post_title', 'title', 'quantity', 'payment_type', 'line_meta');
68 + $query->select('id', 'order_id', 'object_id', 'post_title', 'title', 'quantity', 'payment_type', 'line_meta', 'other_info');
69 69 }])
70 70 ->where('customer_id', $customer->id)
71 71 ->where(function ($query) {
72 72 $query
@@ -81,11 +81,12 @@
81 81 ->paginate($perPage, ['*'], 'page', $page);
82 82
83 83 $orders->transform(function ($order) {
84 84 return [
85 - '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'),
86 86 'invoice_no' => $order->invoice_no,
87 87 'total_amount' => $order->total_amount,
88 + 'currency' => $order->currency,
88 89 'uuid' => $order->uuid,
89 90 'type' => $order->type,
90 91 'status' => $order->status,
91 92 'renewals_count' => $order->renewals_count,
@@ -90,14 +91,15 @@
90 91 'status' => $order->status,
91 92 'renewals_count' => $order->renewals_count,
92 93 'order_items' => $order->order_items->map(function ($item) {
93 94 return [
94 - 'id' => $item->id,
95 - 'post_title' => $item->post_title,
96 - 'title' => $item->title,
97 - 'quantity' => $item->quantity,
98 - 'payment_type' => $item->payment_type,
99 - 'line_meta' => [
95 + 'id' => $item->id,
96 + 'post_title' => $item->post_title,
97 + 'title' => $item->title,
98 + 'variation_display_title' => $item->variation_display_title,
99 + 'quantity' => $item->quantity,
100 + 'payment_type' => $item->payment_type,
101 + 'line_meta' => [
100 102 'bundle_parent_item_id' => Arr::get($item, 'line_meta.bundle_parent_item_id', null),
101 103 ]
102 104 ];
103 105 }),
@@ -166,8 +168,9 @@
166 168
167 169 $orderItems = [];
168 170 $variationIds = [];
169 171 $productIds = [];
172 +
170 173 foreach ($order->order_items as $item) {
171 174 if ($item->payment_type === 'signup_fee') {
172 175 $orderItems[] = [
173 176 'id' => $item->id,
@@ -213,8 +216,9 @@
213 216 'variation_id' => $item->object_id,
214 217 'product_id' => $item->post_id,
215 218 'post_title' => $item->post_title,
216 219 'title' => $item->title,
220 + 'variation_display_title' => $item->variation_display_title,
217 221 'quantity' => $item->quantity,
218 222 'unit_price' => $item->unit_price,
219 223 'subtotal' => $item->subtotal,
220 224 'payment_type' => $item->payment_type,
@@ -223,10 +227,10 @@
223 227 'image' => Arr::get($item, 'productImage.meta_value.0.url', ''),
224 228 'variant_image' => Arr::get($item, 'variantImages.meta_value.0.url', ''),
225 229 'url' => $item->is_custom
226 230 ? ($item->view_url ?? '') : ($item->product->view_url ?? ''),
227 - 'line_meta' => $item->line_meta,
228 - 'id' => $item->id,
231 + 'line_meta' => $item->line_meta,
232 + 'id' => $item->id,
229 233 'coupon_discount' => (int) $item->coupon_discount,
230 234 'discount_total' => (int) $item->discount_total,
231 235 'line_total' => (int) $item->line_total,
232 236
@@ -234,12 +238,35 @@
234 238 $variationIds[] = $item->object_id;
235 239 $productIds[] = $item->post_id;
236 240 }
237 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 +
238 265 $formattedOrderData = [
239 266 'fulfillment_type' => $order->fulfillment_type,
240 267 'type' => $order->type,
241 - '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'),
242 269 'invoice_no' => $order->invoice_no,
243 270 'currency' => $order->currency,
244 271 'uuid' => $order->uuid,
245 272 'order_items' => $orderItems,
@@ -255,8 +282,9 @@
255 282 'total_amount' => $order->total_amount,
256 283 'total_paid' => $order->total_paid,
257 284 'total_refund' => $order->total_refund,
258 285 'shipping_total' => $order->shipping_total,
286 + 'shipping_method_title' => (string) Arr::get($order->config, 'shipping_method_title', ''),
259 287 'coupon_discount_total' => $order->coupon_discount_total,
260 288 'manual_discount_total' => $order->manual_discount_total,
261 289 'prorate_credit' => (int) Arr::get($order->config, 'prorate_credit', 0),
262 290 'tax_total' => $order->tax_total,
@@ -310,9 +338,11 @@
310 338 $transactions = OrderTransaction::query()
311 339 ->whereIn('order_id', $orderIds)
312 340 ->whereIn('status', [
313 341 Status::TRANSACTION_SUCCEEDED,
314 - Status::TRANSACTION_REFUNDED
342 + Status::TRANSACTION_REFUNDED,
343 + Status::TRANSACTION_FAILED,
344 + Status::TRANSACTION_PENDING,
315 345 ])
316 346 ->orderBy('id', 'DESC')
317 347 ->with(['order'])
318 348 ->get();
@@ -317,9 +347,15 @@
317 347 ->with(['order'])
318 348 ->get();
319 349
320 350 $formattedOrderData['transactions'] = $transactions->map(function ($transaction) {
321 - return OrderService::transformTransaction($transaction);
351 + $transformedTransaction = OrderService::transformTransaction($transaction);
352 + if ($transaction->status === Status::TRANSACTION_PENDING
353 + && !empty($transformedTransaction['custom_checkout_url'])
354 + ) {
355 + $transformedTransaction['show_pay_now'] = true;
356 + }
357 + return $transformedTransaction;
322 358 });
323 359
324 360 $formattedOrderData = apply_filters('fluent_cart/customer/order_data', $formattedOrderData, [
325 361 'order' => $order,
@@ -393,8 +429,16 @@
393 429 {
394 430 if (!intval($order->total_amount - $order->total_paid)) {
395 431 return false;
396 432 }
433 +
434 + if ($order->parent_id) {
435 + $subscription = Subscription::query()->where('parent_order_id', $order->parent_id)->first();
436 + if ($subscription && $subscription->isSystem() && !SystemChargeService::isExhausted($subscription, $order)) {
437 + return false;
438 + }
439 + }
440 +
397 441 return PaymentHelper::getCustomPaymentLink($order->uuid);
398 442 }
399 443
400 444 public function getTransactionBillingAddress(Request $request, $transaction_uuid)