@fleetbase/storefront-engine 0.3.1 → 0.3.2
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/schedule-manager.js +2 -2
- package/addon/controllers/networks/index/network/index.js +7 -0
- package/composer.json +3 -3
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/src/Expansions/EntityExpansion.php +6 -4
- package/server/src/Http/Controllers/v1/CheckoutController.php +15 -23
- package/server/src/Models/Checkout.php +2 -2
- package/server/src/Models/StoreLocation.php +2 -0
- package/server/src/routes.php +2 -2
|
@@ -44,8 +44,8 @@ export default class ScheduleManagerComponent extends Component {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
this.modalsManager.show('modals/add-store-hours', {
|
|
47
|
-
title: this.intl.t('storefront.component.schedule-manager.add-new-hours-for-day', {
|
|
48
|
-
acceptButtonText: this.intl.t('storefront.component.schedule-manager
|
|
47
|
+
title: this.intl.t('storefront.component.schedule-manager.add-new-hours-for-day', { day: day }),
|
|
48
|
+
acceptButtonText: this.intl.t('storefront.component.schedule-manager.add-hours'),
|
|
49
49
|
acceptButtonIcon: 'save',
|
|
50
50
|
hours,
|
|
51
51
|
confirm: (modal) => {
|
|
@@ -49,6 +49,13 @@ export default class NetworksIndexNetworkIndexController extends Controller {
|
|
|
49
49
|
*/
|
|
50
50
|
@service intl;
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Store service to handle file uploads and other network requests.
|
|
54
|
+
*
|
|
55
|
+
* @property {Service} store
|
|
56
|
+
*/
|
|
57
|
+
@service store;
|
|
58
|
+
|
|
52
59
|
/**
|
|
53
60
|
* Proof of delivery methods.
|
|
54
61
|
*
|
package/composer.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetbase/storefront-api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Headless Commerce & Marketplace Extension for Fleetbase",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fleetbase-extension",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"require": {
|
|
24
24
|
"php": "^8.0",
|
|
25
|
-
"fleetbase/core-api": "^1.4.
|
|
26
|
-
"fleetbase/fleetops-api": "^0.4.
|
|
25
|
+
"fleetbase/core-api": "^1.4.9",
|
|
26
|
+
"fleetbase/fleetops-api": "^0.4.15",
|
|
27
27
|
"geocoder-php/google-maps-places-provider": "^1.4",
|
|
28
28
|
"laravel-notification-channels/apn": "^5.0",
|
|
29
29
|
"laravel-notification-channels/fcm": "^4.1",
|
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
namespace Fleetbase\Storefront\Expansions;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Build\Expansion;
|
|
6
|
+
use Fleetbase\FleetOps\Models\Entity;
|
|
7
|
+
use Fleetbase\Storefront\Models\Product;
|
|
6
8
|
|
|
7
9
|
class EntityExpansion implements Expansion
|
|
8
10
|
{
|
|
@@ -13,18 +15,18 @@ class EntityExpansion implements Expansion
|
|
|
13
15
|
*/
|
|
14
16
|
public static function target()
|
|
15
17
|
{
|
|
16
|
-
return
|
|
18
|
+
return Entity::class;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* Create a new Entity from a Storefront Product.
|
|
21
23
|
*
|
|
22
|
-
* @return
|
|
24
|
+
* @return Entity
|
|
23
25
|
*/
|
|
24
26
|
public function fromStorefrontProduct()
|
|
25
27
|
{
|
|
26
|
-
return static function (
|
|
27
|
-
return new
|
|
28
|
+
return static function (Product $product) {
|
|
29
|
+
return new Entity([
|
|
28
30
|
'company_uuid' => session('company'),
|
|
29
31
|
'photo_uuid' => $product->primary_image_uuid,
|
|
30
32
|
'internal_id' => $product->public_id,
|
|
@@ -17,6 +17,7 @@ use Fleetbase\Storefront\Http\Requests\CaptureOrderRequest;
|
|
|
17
17
|
use Fleetbase\Storefront\Http\Requests\InitializeCheckoutRequest;
|
|
18
18
|
use Fleetbase\Storefront\Models\Cart;
|
|
19
19
|
use Fleetbase\Storefront\Models\Checkout;
|
|
20
|
+
use Fleetbase\Storefront\Models\Customer;
|
|
20
21
|
use Fleetbase\Storefront\Models\Gateway;
|
|
21
22
|
use Fleetbase\Storefront\Models\Product;
|
|
22
23
|
use Fleetbase\Storefront\Models\Store;
|
|
@@ -53,7 +54,7 @@ class CheckoutController extends Controller
|
|
|
53
54
|
// find and validate cart session
|
|
54
55
|
$cart = Cart::retrieve($cartId);
|
|
55
56
|
$gateway = Storefront::findGateway($gatewayCode);
|
|
56
|
-
$customer =
|
|
57
|
+
$customer = Customer::findFromCustomerId($customerId);
|
|
57
58
|
$serviceQuote = ServiceQuote::select(['amount', 'meta', 'uuid', 'public_id'])->where('public_id', $serviceQuoteId)->first();
|
|
58
59
|
|
|
59
60
|
// handle cash orders
|
|
@@ -113,7 +114,7 @@ class CheckoutController extends Controller
|
|
|
113
114
|
'gateway_uuid' => $gateway->uuid ?? null,
|
|
114
115
|
'service_quote_uuid' => $serviceQuote->uuid,
|
|
115
116
|
'owner_uuid' => $customer->uuid,
|
|
116
|
-
'owner_type' => 'contact',
|
|
117
|
+
'owner_type' => 'fleet-ops:contact',
|
|
117
118
|
'amount' => $amount,
|
|
118
119
|
'currency' => $currency,
|
|
119
120
|
'is_cod' => true,
|
|
@@ -187,7 +188,7 @@ class CheckoutController extends Controller
|
|
|
187
188
|
'gateway_uuid' => $gateway->uuid,
|
|
188
189
|
'service_quote_uuid' => $serviceQuote->uuid,
|
|
189
190
|
'owner_uuid' => $customer->uuid,
|
|
190
|
-
'owner_type' => 'contact',
|
|
191
|
+
'owner_type' => 'fleet-ops:contact',
|
|
191
192
|
'amount' => $amount,
|
|
192
193
|
'currency' => $currency,
|
|
193
194
|
'is_pickup' => $isPickup,
|
|
@@ -249,7 +250,7 @@ class CheckoutController extends Controller
|
|
|
249
250
|
'gateway_uuid' => $gateway->uuid,
|
|
250
251
|
'service_quote_uuid' => $serviceQuote->uuid,
|
|
251
252
|
'owner_uuid' => $customer->uuid,
|
|
252
|
-
'owner_type' => 'contact',
|
|
253
|
+
'owner_type' => 'fleet-ops:contact',
|
|
253
254
|
'amount' => $amount,
|
|
254
255
|
'currency' => $currency,
|
|
255
256
|
'is_pickup' => $isPickup,
|
|
@@ -345,7 +346,7 @@ class CheckoutController extends Controller
|
|
|
345
346
|
$transaction = Transaction::create([
|
|
346
347
|
'company_uuid' => session('company'),
|
|
347
348
|
'customer_uuid' => $customer->uuid,
|
|
348
|
-
'customer_type' => 'contact',
|
|
349
|
+
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
|
|
349
350
|
'gateway_transaction_id' => Utils::or($transactionDetails, ['id', 'transaction_id']) ?? Transaction::generateNumber(),
|
|
350
351
|
'gateway' => $gateway->code,
|
|
351
352
|
'gateway_uuid' => $gateway->uuid,
|
|
@@ -458,18 +459,7 @@ class CheckoutController extends Controller
|
|
|
458
459
|
// create entities
|
|
459
460
|
foreach ($cart->items as $cartItem) {
|
|
460
461
|
$product = Product::where('public_id', $cartItem->product_id)->first();
|
|
461
|
-
$entity = Entity::fromStorefrontProduct($product)
|
|
462
|
-
'company_uuid' => session('company'),
|
|
463
|
-
'payload_uuid' => $payload->uuid,
|
|
464
|
-
'customer_uuid' => $customer->uuid,
|
|
465
|
-
'customer_type' => 'contact',
|
|
466
|
-
])->setMetas([
|
|
467
|
-
'variants' => $cartItem->variants,
|
|
468
|
-
'addons' => $cartItem->addons,
|
|
469
|
-
'subtotal' => $cartItem->subtotal,
|
|
470
|
-
'quantity' => $cartItem->quantity,
|
|
471
|
-
'scheduled_at' => $cartItem->scheduled_at ?? null,
|
|
472
|
-
]);
|
|
462
|
+
$entity = Entity::fromStorefrontProduct($product);
|
|
473
463
|
|
|
474
464
|
$entity->save();
|
|
475
465
|
}
|
|
@@ -505,7 +495,7 @@ class CheckoutController extends Controller
|
|
|
505
495
|
'company_uuid' => $store->company_uuid ?? session('company'),
|
|
506
496
|
'payload_uuid' => $payload->uuid,
|
|
507
497
|
'customer_uuid' => $customer->uuid,
|
|
508
|
-
'customer_type' => 'contact',
|
|
498
|
+
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
|
|
509
499
|
'transaction_uuid' => $transaction->uuid,
|
|
510
500
|
'adhoc' => $about->isOption('auto_dispatch'),
|
|
511
501
|
'type' => 'storefront',
|
|
@@ -525,6 +515,8 @@ class CheckoutController extends Controller
|
|
|
525
515
|
// create order
|
|
526
516
|
$order = Order::create($orderInput);
|
|
527
517
|
|
|
518
|
+
info('Order created', $order->toArray());
|
|
519
|
+
|
|
528
520
|
// notify order creation
|
|
529
521
|
Storefront::alertNewOrder($order);
|
|
530
522
|
|
|
@@ -610,7 +602,7 @@ class CheckoutController extends Controller
|
|
|
610
602
|
$transaction = Transaction::create([
|
|
611
603
|
'company_uuid' => session('company'),
|
|
612
604
|
'customer_uuid' => $customer->uuid,
|
|
613
|
-
'customer_type' => 'contact',
|
|
605
|
+
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
|
|
614
606
|
'gateway_transaction_id' => Utils::or($transactionDetails, ['id', 'transaction_id']) ?? Transaction::generateNumber(),
|
|
615
607
|
'gateway' => $gateway->code,
|
|
616
608
|
'gateway_uuid' => $gateway->uuid,
|
|
@@ -706,7 +698,7 @@ class CheckoutController extends Controller
|
|
|
706
698
|
'company_uuid' => $store->company_uuid,
|
|
707
699
|
'payload_uuid' => $payload->uuid,
|
|
708
700
|
'customer_uuid' => $customer->uuid,
|
|
709
|
-
'customer_type' => 'contact',
|
|
701
|
+
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
|
|
710
702
|
])->setMetas([
|
|
711
703
|
'variants' => $cartItem->variants,
|
|
712
704
|
'addons' => $cartItem->addons,
|
|
@@ -746,7 +738,7 @@ class CheckoutController extends Controller
|
|
|
746
738
|
'company_uuid' => $store->company_uuid,
|
|
747
739
|
'payload_uuid' => $payload->uuid,
|
|
748
740
|
'customer_uuid' => $customer->uuid,
|
|
749
|
-
'customer_type' => 'contact',
|
|
741
|
+
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
|
|
750
742
|
'transaction_uuid' => $transaction->uuid,
|
|
751
743
|
'adhoc' => $about->isOption('auto_dispatch'),
|
|
752
744
|
'type' => 'storefront',
|
|
@@ -811,7 +803,7 @@ class CheckoutController extends Controller
|
|
|
811
803
|
'company_uuid' => session('company'),
|
|
812
804
|
'payload_uuid' => $payload->uuid,
|
|
813
805
|
'customer_uuid' => $customer->uuid,
|
|
814
|
-
'customer_type' => 'contact',
|
|
806
|
+
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
|
|
815
807
|
])->setMetas([
|
|
816
808
|
'variants' => $cartItem->variants,
|
|
817
809
|
'addons' => $cartItem->addons,
|
|
@@ -849,7 +841,7 @@ class CheckoutController extends Controller
|
|
|
849
841
|
'company_uuid' => session('company'),
|
|
850
842
|
'payload_uuid' => $payload->uuid,
|
|
851
843
|
'customer_uuid' => $customer->uuid,
|
|
852
|
-
'customer_type' => 'contact',
|
|
844
|
+
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
|
|
853
845
|
'transaction_uuid' => $transaction->uuid,
|
|
854
846
|
'adhoc' => $about->isOption('auto_dispatch'),
|
|
855
847
|
'type' => 'storefront',
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
namespace Fleetbase\Storefront\Models;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Casts\Json;
|
|
6
|
-
use Fleetbase\FleetOps\
|
|
6
|
+
use Fleetbase\FleetOps\Models\ServiceQuote;
|
|
7
7
|
use Fleetbase\Models\Company;
|
|
8
|
-
use Fleetbase\
|
|
8
|
+
use Fleetbase\Support\Utils;
|
|
9
9
|
use Fleetbase\Traits\HasOptionsAttributes;
|
|
10
10
|
use Fleetbase\Traits\HasPublicid;
|
|
11
11
|
use Fleetbase\Traits\HasUuid;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\Storefront\Models;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\FleetOps\Models\Place;
|
|
6
|
+
use Fleetbase\LaravelMysqlSpatial\Eloquent\SpatialTrait;
|
|
6
7
|
use Fleetbase\Models\User;
|
|
7
8
|
use Fleetbase\Traits\HasApiModelBehavior;
|
|
8
9
|
use Fleetbase\Traits\HasPublicid;
|
|
@@ -13,6 +14,7 @@ class StoreLocation extends StorefrontModel
|
|
|
13
14
|
use HasUuid;
|
|
14
15
|
use HasPublicid;
|
|
15
16
|
use HasApiModelBehavior;
|
|
17
|
+
use SpatialTrait;
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* The type of public Id to generate.
|
package/server/src/routes.php
CHANGED
|
@@ -39,7 +39,7 @@ Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace(
|
|
|
39
39
|
// storefront/v1/checkouts
|
|
40
40
|
$router->group(['prefix' => 'checkouts'], function () use ($router) {
|
|
41
41
|
$router->get('before', 'CheckoutController@beforeCheckout');
|
|
42
|
-
$router->
|
|
42
|
+
$router->post('capture', 'CheckoutController@captureOrder');
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
// storefront/v1/service-quotes
|
|
@@ -105,7 +105,7 @@ Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace(
|
|
|
105
105
|
*/
|
|
106
106
|
$router->prefix(config('storefront.api.routing.internal_prefix', 'int'))->group(
|
|
107
107
|
function ($router) {
|
|
108
|
-
$router->group(['prefix' => '
|
|
108
|
+
$router->group(['prefix' => 'v1'], function () use ($router) {
|
|
109
109
|
$router->get('networks/find/{id}', 'NetworkController@findNetwork');
|
|
110
110
|
});
|
|
111
111
|
|