@fleetbase/storefront-engine 0.3.18 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/components/customer-panel/orders.hbs +107 -104
- package/addon/components/customer-panel/orders.js +52 -45
- package/addon/components/modals/incoming-order.hbs +208 -199
- package/addon/components/modals/order-ready-assign-driver.hbs +1 -1
- package/addon/components/order-panel/details.js +0 -2
- package/addon/components/order-panel.hbs +314 -1
- package/addon/components/order-panel.js +51 -3
- package/addon/components/widget/customers.hbs +75 -51
- package/addon/components/widget/customers.js +29 -41
- package/addon/components/widget/orders.hbs +278 -119
- package/addon/components/widget/orders.js +75 -80
- package/addon/components/widget/storefront-metrics.hbs +3 -6
- package/addon/components/widget/storefront-metrics.js +25 -41
- package/addon/controllers/orders/index.js +214 -105
- package/addon/controllers/settings/gateways.js +1 -1
- package/addon/helpers/get-tip-amount.js +13 -2
- package/addon/routes/application.js +2 -4
- package/addon/services/order-actions.js +248 -0
- package/addon/services/storefront.js +2 -0
- package/addon/styles/storefront-engine.css +48 -0
- package/addon/templates/home.hbs +2 -1
- package/addon/templates/orders/index/view.hbs +1 -1
- package/addon/templates/orders/index.hbs +26 -3
- package/addon/templates/products/index/index.hbs +28 -28
- package/addon/templates/settings.hbs +1 -1
- package/app/services/order-actions.js +1 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/migrations/2023_05_03_025307_create_carts_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_checkouts_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_gateways_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_network_stores_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_networks_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_notification_channels_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_payment_methods_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_addon_categories_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_addons_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_hours_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_store_locations_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_variant_options_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_product_variants_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_products_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_reviews_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_store_hours_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_store_locations_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_stores_table.php +1 -1
- package/server/migrations/2023_05_03_025307_create_votes_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_carts_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_checkouts_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_gateways_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_network_stores_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_networks_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_notification_channels_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_payment_methods_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_addon_categories_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_addons_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_hours_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_store_locations_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_variant_options_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_variants_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_products_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_reviews_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_store_hours_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_store_locations_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_stores_table.php +1 -1
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_votes_table.php +1 -1
- package/server/src/Http/Controllers/ActionController.php +2 -1
- package/server/src/Http/Controllers/OrderController.php +15 -2
- package/server/src/Http/Controllers/v1/CheckoutController.php +11 -12
- package/server/src/Http/Controllers/v1/CustomerController.php +11 -3
- package/server/src/Http/Controllers/v1/ServiceQuoteController.php +5 -5
- package/server/src/Http/Requests/CreateCustomerRequest.php +4 -0
- package/server/src/Http/Requests/InitializeCheckoutRequest.php +2 -1
- package/server/src/Models/Store.php +2 -2
- package/server/src/Observers/OrderObserver.php +7 -1
- package/server/src/Rules/IsValidLocation.php +2 -2
- package/server/src/Support/Storefront.php +34 -0
- package/translations/en-us.yaml +6 -1
|
@@ -87,9 +87,10 @@ class ActionController extends Controller
|
|
|
87
87
|
->where('meta->storefront_id', $store->public_id)
|
|
88
88
|
->with(['transaction'])
|
|
89
89
|
->whereNotIn('status', ['canceled'])
|
|
90
|
+
->whereNull('deleted_at')
|
|
90
91
|
->get()
|
|
91
92
|
->sum(function ($order) {
|
|
92
|
-
return $order
|
|
93
|
+
return data_get($order, 'meta.total');
|
|
93
94
|
});
|
|
94
95
|
|
|
95
96
|
return response()->json($metrics);
|
|
@@ -5,6 +5,7 @@ namespace Fleetbase\Storefront\Http\Controllers;
|
|
|
5
5
|
use Fleetbase\FleetOps\Http\Controllers\Internal\v1\OrderController as FleetbaseOrderController;
|
|
6
6
|
use Fleetbase\FleetOps\Models\Order;
|
|
7
7
|
use Fleetbase\Storefront\Notifications\StorefrontOrderPreparing;
|
|
8
|
+
use Fleetbase\Storefront\Support\Storefront;
|
|
8
9
|
use Illuminate\Http\Request;
|
|
9
10
|
|
|
10
11
|
class OrderController extends FleetbaseOrderController
|
|
@@ -38,6 +39,9 @@ class OrderController extends FleetbaseOrderController
|
|
|
38
39
|
], 400);
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
// Patch order config
|
|
43
|
+
Storefront::patchOrderConfig($order);
|
|
44
|
+
|
|
41
45
|
// update activity to prepating
|
|
42
46
|
$order->updateStatus('preparing');
|
|
43
47
|
$order->customer->notify(new StorefrontOrderPreparing($order));
|
|
@@ -58,7 +62,7 @@ class OrderController extends FleetbaseOrderController
|
|
|
58
62
|
{
|
|
59
63
|
$adhoc = $request->boolean('adhoc');
|
|
60
64
|
$driver = $request->input('driver');
|
|
61
|
-
/** @var
|
|
65
|
+
/** @var Order $order */
|
|
62
66
|
$order = Order::where('uuid', $request->order)->whereNull('deleted_at')->with(['customer'])->first();
|
|
63
67
|
|
|
64
68
|
if (!$order) {
|
|
@@ -67,8 +71,11 @@ class OrderController extends FleetbaseOrderController
|
|
|
67
71
|
], 400);
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
// Patch order config
|
|
75
|
+
Storefront::patchOrderConfig($order);
|
|
76
|
+
|
|
70
77
|
if ($order->isMeta('is_pickup')) {
|
|
71
|
-
$order->updateStatus('
|
|
78
|
+
$order->updateStatus('pickup_ready');
|
|
72
79
|
|
|
73
80
|
return response()->json([
|
|
74
81
|
'status' => 'ok',
|
|
@@ -113,6 +120,9 @@ class OrderController extends FleetbaseOrderController
|
|
|
113
120
|
], 400);
|
|
114
121
|
}
|
|
115
122
|
|
|
123
|
+
// Patch order config
|
|
124
|
+
Storefront::patchOrderConfig($order);
|
|
125
|
+
|
|
116
126
|
// update activity to completed
|
|
117
127
|
$order->updateStatus('completed');
|
|
118
128
|
|
|
@@ -138,6 +148,9 @@ class OrderController extends FleetbaseOrderController
|
|
|
138
148
|
], 400);
|
|
139
149
|
}
|
|
140
150
|
|
|
151
|
+
// Patch order config
|
|
152
|
+
Storefront::patchOrderConfig($order);
|
|
153
|
+
|
|
141
154
|
// update activity to dispatched
|
|
142
155
|
$order->updateStatus('cancel');
|
|
143
156
|
|
|
@@ -132,7 +132,7 @@ class CheckoutController extends Controller
|
|
|
132
132
|
]);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
public static function initializeStripeCheckout(Contact $customer, Gateway $gateway, ServiceQuote $serviceQuote, Cart $cart, $checkoutOptions)
|
|
135
|
+
public static function initializeStripeCheckout(Contact $customer, Gateway $gateway, ?ServiceQuote $serviceQuote, Cart $cart, $checkoutOptions)
|
|
136
136
|
{
|
|
137
137
|
// check if pickup order
|
|
138
138
|
$isPickup = $checkoutOptions->is_pickup;
|
|
@@ -202,7 +202,7 @@ class CheckoutController extends Controller
|
|
|
202
202
|
'network_uuid' => session('storefront_network'),
|
|
203
203
|
'cart_uuid' => $cart->uuid,
|
|
204
204
|
'gateway_uuid' => $gateway->uuid,
|
|
205
|
-
'service_quote_uuid' => $serviceQuote->uuid,
|
|
205
|
+
'service_quote_uuid' => $serviceQuote ? $serviceQuote->uuid : null,
|
|
206
206
|
'owner_uuid' => $customer->uuid,
|
|
207
207
|
'owner_type' => 'fleet-ops:contact',
|
|
208
208
|
'amount' => $amount,
|
|
@@ -327,9 +327,6 @@ class CheckoutController extends Controller
|
|
|
327
327
|
$serviceQuote = ServiceQuote::select(['amount', 'meta', 'uuid', 'public_id'])
|
|
328
328
|
->where('public_id', $serviceQuoteId)
|
|
329
329
|
->first();
|
|
330
|
-
if (!$serviceQuote) {
|
|
331
|
-
return response()->apiError('Invalid service quote ID provided');
|
|
332
|
-
}
|
|
333
330
|
|
|
334
331
|
// Recalculate amount based on cart, serviceQuote, and checkoutOptions
|
|
335
332
|
$amount = static::calculateCheckoutAmount($cart, $serviceQuote, $checkoutOptions);
|
|
@@ -398,7 +395,7 @@ class CheckoutController extends Controller
|
|
|
398
395
|
'network_uuid' => session('storefront_network'),
|
|
399
396
|
'cart_uuid' => $cart->uuid,
|
|
400
397
|
'gateway_uuid' => $gateway->uuid,
|
|
401
|
-
'service_quote_uuid' => $serviceQuote->uuid,
|
|
398
|
+
'service_quote_uuid' => $serviceQuote ? $serviceQuote->uuid : null,
|
|
402
399
|
'owner_uuid' => $customer->uuid,
|
|
403
400
|
'owner_type' => 'fleet-ops:contact',
|
|
404
401
|
'amount' => $amount,
|
|
@@ -418,7 +415,7 @@ class CheckoutController extends Controller
|
|
|
418
415
|
]);
|
|
419
416
|
}
|
|
420
417
|
|
|
421
|
-
public static function initializeQPayCheckout(Contact $customer, Gateway $gateway, ServiceQuote $serviceQuote, Cart $cart, $checkoutOptions)
|
|
418
|
+
public static function initializeQPayCheckout(Contact $customer, Gateway $gateway, ?ServiceQuote $serviceQuote, Cart $cart, $checkoutOptions)
|
|
422
419
|
{
|
|
423
420
|
// Get store info
|
|
424
421
|
$about = Storefront::about();
|
|
@@ -455,7 +452,7 @@ class CheckoutController extends Controller
|
|
|
455
452
|
'network_uuid' => session('storefront_network'),
|
|
456
453
|
'cart_uuid' => $cart->uuid,
|
|
457
454
|
'gateway_uuid' => $gateway->uuid,
|
|
458
|
-
'service_quote_uuid' => $serviceQuote->uuid,
|
|
455
|
+
'service_quote_uuid' => $serviceQuote ? $serviceQuote->uuid : null,
|
|
459
456
|
'owner_uuid' => $customer->uuid,
|
|
460
457
|
'owner_type' => 'fleet-ops:contact',
|
|
461
458
|
'amount' => $amount,
|
|
@@ -612,8 +609,8 @@ class CheckoutController extends Controller
|
|
|
612
609
|
$customer = $checkout->owner;
|
|
613
610
|
$serviceQuote = $checkout->serviceQuote;
|
|
614
611
|
$gateway = $checkout->is_cod ? Gateway::cash() : $checkout->gateway;
|
|
615
|
-
$origin = $serviceQuote->getMeta('origin', []);
|
|
616
|
-
$destination = $serviceQuote->getMeta('destination');
|
|
612
|
+
$origin = $serviceQuote ? $serviceQuote->getMeta('origin', []) : null;
|
|
613
|
+
$destination = $serviceQuote ? $serviceQuote->getMeta('destination') : null;
|
|
617
614
|
$cart = $checkout->cart;
|
|
618
615
|
|
|
619
616
|
// if cart is null then cart has either been deleted or expired
|
|
@@ -848,7 +845,9 @@ class CheckoutController extends Controller
|
|
|
848
845
|
Storefront::alertNewOrder($order);
|
|
849
846
|
|
|
850
847
|
// purchase service quote
|
|
851
|
-
|
|
848
|
+
if ($serviceQuote) {
|
|
849
|
+
$order->purchaseQuote($serviceQuote->uuid, $transactionDetails);
|
|
850
|
+
}
|
|
852
851
|
|
|
853
852
|
// if order is auto accepted update status
|
|
854
853
|
if ($about->isOption('auto_accept_orders')) {
|
|
@@ -1199,7 +1198,7 @@ class CheckoutController extends Controller
|
|
|
1199
1198
|
*
|
|
1200
1199
|
* @param stdClass $checkoutOptions
|
|
1201
1200
|
*/
|
|
1202
|
-
private static function calculateCheckoutAmount(Cart $cart, ServiceQuote $serviceQuote, $checkoutOptions): int
|
|
1201
|
+
private static function calculateCheckoutAmount(Cart $cart, ?ServiceQuote $serviceQuote, $checkoutOptions): int
|
|
1203
1202
|
{
|
|
1204
1203
|
// cast checkout options to object always
|
|
1205
1204
|
$checkoutOptions = (object) $checkoutOptions;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\Storefront\Http\Controllers\v1;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\FleetOps\Exceptions\UserAlreadyExistsException;
|
|
5
6
|
use Fleetbase\FleetOps\Http\Requests\UpdateContactRequest;
|
|
6
7
|
use Fleetbase\FleetOps\Http\Resources\v1\DeletedResource;
|
|
7
8
|
use Fleetbase\FleetOps\Http\Resources\v1\Order as OrderResource;
|
|
@@ -174,7 +175,6 @@ class CustomerController extends Controller
|
|
|
174
175
|
|
|
175
176
|
// verify code
|
|
176
177
|
$isVerified = VerificationCode::where(['code' => $code, 'for' => 'storefront_create_customer', 'meta->identity' => $identity])->exists();
|
|
177
|
-
|
|
178
178
|
if (!$isVerified) {
|
|
179
179
|
return response()->error('Invalid verification code provided!');
|
|
180
180
|
}
|
|
@@ -209,13 +209,21 @@ class CustomerController extends Controller
|
|
|
209
209
|
];
|
|
210
210
|
|
|
211
211
|
// create the customer/contact
|
|
212
|
-
|
|
212
|
+
try {
|
|
213
|
+
$customer = Contact::create($input);
|
|
214
|
+
} catch (UserAlreadyExistsException $e) {
|
|
215
|
+
// If the exception is thrown because user already exists and
|
|
216
|
+
// that user is the same user already assigned continue
|
|
217
|
+
$customer = Contact::where(['company_uuid' => session('company'), 'phone' => $input['phone']])->first();
|
|
218
|
+
} catch (\Exception $e) {
|
|
219
|
+
return response()->apiError($e->getMessage());
|
|
220
|
+
}
|
|
213
221
|
|
|
214
222
|
// generate auth token
|
|
215
223
|
try {
|
|
216
224
|
$token = $user->createToken($customer->uuid);
|
|
217
225
|
} catch (\Exception $e) {
|
|
218
|
-
return response()->
|
|
226
|
+
return response()->apiError($e->getMessage());
|
|
219
227
|
}
|
|
220
228
|
|
|
221
229
|
$customer->token = $token->plainTextToken;
|
|
@@ -371,13 +371,13 @@ class ServiceQuoteController extends Controller
|
|
|
371
371
|
|
|
372
372
|
/**
|
|
373
373
|
* Returns a place from either a place id or store location id.
|
|
374
|
-
*
|
|
375
|
-
* @param string $id
|
|
376
|
-
*
|
|
377
|
-
* @return Place
|
|
378
374
|
*/
|
|
379
|
-
public function getPlaceFromId($id)
|
|
375
|
+
public function getPlaceFromId(string|array $id): ?Place
|
|
380
376
|
{
|
|
377
|
+
if (is_array($id)) {
|
|
378
|
+
$id = implode(',', $id);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
381
|
if (Str::startsWith($id, 'store_location')) {
|
|
382
382
|
$storeLocation = StoreLocation::select(['place_uuid'])->where(['public_id' => $id, 'store_uuid' => session('storefront_store')])->with(['place'])->first();
|
|
383
383
|
|
|
@@ -29,11 +29,15 @@ class CreateCustomerRequest extends FleetbaseRequest
|
|
|
29
29
|
'name' => 'required',
|
|
30
30
|
'email' => [
|
|
31
31
|
'email', 'nullable', Rule::unique('contacts')->where(function ($query) {
|
|
32
|
+
$query->where('company_uuid', session('company'));
|
|
33
|
+
|
|
32
34
|
return $query->whereNull('deleted_at');
|
|
33
35
|
}),
|
|
34
36
|
],
|
|
35
37
|
'phone' => [
|
|
36
38
|
'nullable', Rule::unique('contacts')->where(function ($query) {
|
|
39
|
+
$query->where('company_uuid', session('company'));
|
|
40
|
+
|
|
37
41
|
return $query->whereNull('deleted_at');
|
|
38
42
|
}),
|
|
39
43
|
],
|
|
@@ -5,6 +5,7 @@ namespace Fleetbase\Storefront\Http\Requests;
|
|
|
5
5
|
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
6
|
use Fleetbase\Storefront\Rules\CustomerExists;
|
|
7
7
|
use Fleetbase\Storefront\Rules\GatewayExists;
|
|
8
|
+
use Illuminate\Validation\Rule;
|
|
8
9
|
|
|
9
10
|
class InitializeCheckoutRequest extends FleetbaseRequest
|
|
10
11
|
{
|
|
@@ -29,7 +30,7 @@ class InitializeCheckoutRequest extends FleetbaseRequest
|
|
|
29
30
|
'gateway' => ['required', new GatewayExists()],
|
|
30
31
|
'customer' => ['required', new CustomerExists()],
|
|
31
32
|
'cart' => ['required', 'exists:storefront.carts,public_id'],
|
|
32
|
-
'serviceQuote' => ['
|
|
33
|
+
'serviceQuote' => [Rule::requiredIf(fn () => !$this->boolean('pickup')), 'exists:service_quotes,public_id'],
|
|
33
34
|
'cash' => ['sometimes', 'boolean'],
|
|
34
35
|
'pickup' => ['sometimes', 'boolean'],
|
|
35
36
|
];
|
|
@@ -310,7 +310,7 @@ class Store extends StorefrontModel
|
|
|
310
310
|
*
|
|
311
311
|
* @param string $id the ID of the network for which the category is to be retrieved
|
|
312
312
|
*
|
|
313
|
-
* @return
|
|
313
|
+
* @return Category|null the category of the store in the given network, or null if the store does not belong to the network
|
|
314
314
|
*/
|
|
315
315
|
public function getNetworkCategoryUsingId(?string $id)
|
|
316
316
|
{
|
|
@@ -334,7 +334,7 @@ class Store extends StorefrontModel
|
|
|
334
334
|
*
|
|
335
335
|
* @param Network $network the network for which the category is to be retrieved
|
|
336
336
|
*
|
|
337
|
-
* @return
|
|
337
|
+
* @return Category|null the category of the store in the given network, or null if the store does not belong to the network
|
|
338
338
|
*/
|
|
339
339
|
public function getNetworkCategory(Network $network)
|
|
340
340
|
{
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\Storefront\Observers;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\FleetOps\Models\Order;
|
|
6
|
+
use Fleetbase\Storefront\Support\Storefront;
|
|
6
7
|
|
|
7
8
|
class OrderObserver
|
|
8
9
|
{
|
|
@@ -11,7 +12,12 @@ class OrderObserver
|
|
|
11
12
|
*
|
|
12
13
|
* @return void
|
|
13
14
|
*/
|
|
14
|
-
public function
|
|
15
|
+
public function creating(Order $order)
|
|
15
16
|
{
|
|
17
|
+
// Set the storefront order config
|
|
18
|
+
$orderConfig = Storefront::getDefaultOrderConfig();
|
|
19
|
+
if ($orderConfig) {
|
|
20
|
+
$order->order_config_uuid = $orderConfig->uuid;
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
}
|
|
@@ -20,12 +20,12 @@ class IsValidLocation implements Rule
|
|
|
20
20
|
public function passes($attribute, $value)
|
|
21
21
|
{
|
|
22
22
|
// Validate Place id
|
|
23
|
-
if (Str::startsWith($value, 'place_')) {
|
|
23
|
+
if (is_string($value) && Str::startsWith($value, 'place_')) {
|
|
24
24
|
return Place::where('public_id', $value)->exists();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Validate StoreLocation id
|
|
28
|
-
if (Str::startsWith($value, 'store_location_')) {
|
|
28
|
+
if (is_string($value) && Str::startsWith($value, 'store_location_')) {
|
|
29
29
|
return StoreLocation::where('public_id', $value)->exists();
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -12,6 +12,7 @@ use Fleetbase\Storefront\Models\Network;
|
|
|
12
12
|
use Fleetbase\Storefront\Models\Product;
|
|
13
13
|
use Fleetbase\Storefront\Models\Store;
|
|
14
14
|
use Fleetbase\Storefront\Notifications\StorefrontOrderCreated;
|
|
15
|
+
use Fleetbase\Support\Auth;
|
|
15
16
|
use Fleetbase\Support\Utils;
|
|
16
17
|
use Illuminate\Support\Facades\Notification;
|
|
17
18
|
use Illuminate\Support\Facades\Redis;
|
|
@@ -203,6 +204,39 @@ class Storefront
|
|
|
203
204
|
return $stripeCustomer;
|
|
204
205
|
}
|
|
205
206
|
|
|
207
|
+
public static function patchOrderConfig(Order $order)
|
|
208
|
+
{
|
|
209
|
+
$orderConfig = $order->config();
|
|
210
|
+
if (!$orderConfig) {
|
|
211
|
+
$orderConfig = Storefront::getDefaultOrderConfig();
|
|
212
|
+
if ($orderConfig) {
|
|
213
|
+
$order->update(['order_config_uuid' => $orderConfig->uuid]);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return $orderConfig;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public static function getDefaultOrderConfig()
|
|
221
|
+
{
|
|
222
|
+
$company = Auth::getCompany();
|
|
223
|
+
if ($company) {
|
|
224
|
+
return static::getOrderConfig($company);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
public static function getOrderConfig(Company $company)
|
|
231
|
+
{
|
|
232
|
+
$orderConfig = OrderConfig::where(['company_uuid' => $company->uuid, 'key' => 'storefront', 'namespace' => 'system:order-config:storefront'])->first();
|
|
233
|
+
if (!$orderConfig) {
|
|
234
|
+
$orderConfig = static::createStorefrontConfig($company);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return $orderConfig;
|
|
238
|
+
}
|
|
239
|
+
|
|
206
240
|
/**
|
|
207
241
|
* Creates or retrieves an existing storefront configuration for a given company.
|
|
208
242
|
*
|
package/translations/en-us.yaml
CHANGED
|
@@ -226,7 +226,8 @@ storefront:
|
|
|
226
226
|
orders:
|
|
227
227
|
widget-title: Recent Orders
|
|
228
228
|
id-column: Order ID
|
|
229
|
-
|
|
229
|
+
cancel-order: Cancel Order
|
|
230
|
+
accept-order: Accept Order!
|
|
230
231
|
mark-as-ready: Mark as Ready!
|
|
231
232
|
mark-as-completed: Mark as Completed
|
|
232
233
|
more-details: More Details
|
|
@@ -236,8 +237,11 @@ storefront:
|
|
|
236
237
|
delivery-fee: Delivery fee
|
|
237
238
|
delivery-tip: Delivery tip
|
|
238
239
|
tip: Tip
|
|
240
|
+
total: Total
|
|
239
241
|
change-driver: Change Driver
|
|
240
242
|
assign-driver: Assign Driver
|
|
243
|
+
customer-pickup: Customer Pickup
|
|
244
|
+
pickup-order: Pickup Order
|
|
241
245
|
mark-as-ready-modal-pickup-title: Mark order ready for pickup?
|
|
242
246
|
mark-as-ready-modal-pickup-body: Marking the order as ready will notify the customer their order is ready for pickup!
|
|
243
247
|
mark-as-ready-modal-pickup-accept-button-text: Ready for Pickup!
|
|
@@ -429,6 +433,7 @@ storefront:
|
|
|
429
433
|
select-order-dropoff-location: Select order dropoff location
|
|
430
434
|
scheduled-at: Scheduled At
|
|
431
435
|
transaction-total: Transaction Total
|
|
436
|
+
total: Total
|
|
432
437
|
tracking-number: Tracking Number
|
|
433
438
|
driver-assigned: Driver Assigned
|
|
434
439
|
select-driver-for-order: Select driver for order
|