@fleetbase/storefront-engine 0.3.3 → 0.3.5

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.
Files changed (74) hide show
  1. package/.php-cs-fixer.php +2 -0
  2. package/addon/components/modals/create-first-store.hbs +1 -1
  3. package/addon/components/modals/create-network.hbs +1 -1
  4. package/addon/components/modals/create-store.hbs +1 -1
  5. package/addon/components/modals/manage-addons.hbs +1 -1
  6. package/addon/components/modals/store-form.hbs +2 -2
  7. package/addon/components/storefront-order-summary.hbs +73 -0
  8. package/addon/components/storefront-order-summary.js +3 -0
  9. package/addon/components/widget/orders.js +1 -1
  10. package/addon/controllers/networks/index/network/index.js +5 -1
  11. package/addon/controllers/products/index/category/edit.js +1 -1
  12. package/addon/controllers/products/index/category/new.js +4 -5
  13. package/addon/controllers/settings/index.js +5 -1
  14. package/addon/engine.js +4 -0
  15. package/addon/templates/networks/index/network/index.hbs +1 -1
  16. package/addon/templates/products/index/category/new.hbs +10 -5
  17. package/addon/templates/settings/index.hbs +14 -4
  18. package/app/components/storefront-order-summary.js +1 -0
  19. package/composer.json +6 -4
  20. package/extension.json +1 -1
  21. package/package.json +3 -3
  22. package/server/migrations/2023_05_03_025307_create_carts_table.php +1 -2
  23. package/server/migrations/2023_05_03_025307_create_checkouts_table.php +1 -2
  24. package/server/migrations/2023_05_03_025307_create_gateways_table.php +1 -2
  25. package/server/migrations/2023_05_03_025307_create_network_stores_table.php +1 -2
  26. package/server/migrations/2023_05_03_025307_create_networks_table.php +1 -2
  27. package/server/migrations/2023_05_03_025307_create_notification_channels_table.php +1 -2
  28. package/server/migrations/2023_05_03_025307_create_payment_methods_table.php +1 -2
  29. package/server/migrations/2023_05_03_025307_create_product_addon_categories_table.php +1 -2
  30. package/server/migrations/2023_05_03_025307_create_product_addons_table.php +1 -2
  31. package/server/migrations/2023_05_03_025307_create_product_hours_table.php +1 -2
  32. package/server/migrations/2023_05_03_025307_create_product_store_locations_table.php +1 -2
  33. package/server/migrations/2023_05_03_025307_create_product_variant_options_table.php +1 -2
  34. package/server/migrations/2023_05_03_025307_create_product_variants_table.php +1 -2
  35. package/server/migrations/2023_05_03_025307_create_products_table.php +1 -2
  36. package/server/migrations/2023_05_03_025307_create_reviews_table.php +1 -2
  37. package/server/migrations/2023_05_03_025307_create_store_hours_table.php +1 -2
  38. package/server/migrations/2023_05_03_025307_create_store_locations_table.php +1 -2
  39. package/server/migrations/2023_05_03_025307_create_stores_table.php +1 -2
  40. package/server/migrations/2023_05_03_025307_create_votes_table.php +1 -2
  41. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_carts_table.php +3 -4
  42. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_checkouts_table.php +3 -4
  43. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_gateways_table.php +3 -4
  44. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_network_stores_table.php +3 -4
  45. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_networks_table.php +3 -4
  46. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_notification_channels_table.php +3 -4
  47. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_payment_methods_table.php +3 -4
  48. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_addon_categories_table.php +3 -4
  49. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_addons_table.php +3 -4
  50. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_hours_table.php +1 -2
  51. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_store_locations_table.php +1 -2
  52. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_variant_options_table.php +1 -2
  53. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_variants_table.php +1 -2
  54. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_products_table.php +3 -4
  55. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_reviews_table.php +3 -4
  56. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_store_hours_table.php +1 -2
  57. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_store_locations_table.php +3 -4
  58. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_stores_table.php +3 -4
  59. package/server/migrations/2023_05_03_025310_add_foreign_keys_to_votes_table.php +3 -4
  60. package/server/seeders/OrderConfigSeeder.php +23 -0
  61. package/server/src/Expansions/EntityExpansion.php +2 -1
  62. package/server/src/Http/Controllers/v1/CartController.php +0 -12
  63. package/server/src/Http/Controllers/v1/CheckoutController.php +37 -38
  64. package/server/src/Http/Controllers/v1/ServiceQuoteController.php +7 -9
  65. package/server/src/Http/Resources/Network.php +1 -0
  66. package/server/src/Http/Resources/Store.php +1 -0
  67. package/server/src/Models/Cart.php +3 -11
  68. package/server/src/Models/Product.php +2 -5
  69. package/server/src/Observers/CompanyObserver.php +20 -0
  70. package/server/src/Observers/NetworkObserver.php +1 -1
  71. package/server/src/Providers/StorefrontServiceProvider.php +1 -0
  72. package/server/src/Support/Storefront.php +249 -0
  73. package/translations/en-us.yaml +2 -0
  74. package/server/src/Support/OrderConfig.php +0 -14
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
4
4
  use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Support\Facades\Schema;
6
6
 
7
- return new class extends Migration
8
- {
7
+ return new class() extends Migration {
9
8
  /**
10
9
  * Run the migrations.
11
10
  *
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
4
4
  use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Support\Facades\Schema;
6
6
 
7
- return new class extends Migration
8
- {
7
+ return new class() extends Migration {
9
8
  /**
10
9
  * Run the migrations.
11
10
  *
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
4
4
  use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Support\Facades\Schema;
6
6
 
7
- return new class extends Migration
8
- {
7
+ return new class() extends Migration {
9
8
  /**
10
9
  * Run the migrations.
11
10
  *
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
4
4
  use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Support\Facades\Schema;
6
6
 
7
- return new class extends Migration
8
- {
7
+ return new class() extends Migration {
9
8
  /**
10
9
  * Run the migrations.
11
10
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
4
4
  use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Support\Facades\Schema;
6
6
 
7
- return new class extends Migration
8
- {
7
+ return new class() extends Migration {
9
8
  /**
10
9
  * Run the migrations.
11
10
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -1,13 +1,12 @@
1
1
  <?php
2
2
 
3
+ use Fleetbase\Support\Utils;
3
4
  use Illuminate\Database\Migrations\Migration;
4
- use Illuminate\Database\Schema\Blueprint;
5
5
  use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
6
7
  use Illuminate\Support\Facades\Schema;
7
- use Fleetbase\Support\Utils;
8
8
 
9
- return new class extends Migration
10
- {
9
+ return new class() extends Migration {
11
10
  /**
12
11
  * Run the migrations.
13
12
  *
@@ -0,0 +1,23 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Seeders;
4
+
5
+ use Fleetbase\Models\Company;
6
+ use Fleetbase\Storefront\Support\Storefront;
7
+ use Illuminate\Database\Seeder;
8
+
9
+ class OrderConfigSeeder extends Seeder
10
+ {
11
+ /**
12
+ * Run the database seeds.
13
+ *
14
+ * @return void
15
+ */
16
+ public function run()
17
+ {
18
+ $companies = Company::all();
19
+ foreach ($companies as $company) {
20
+ Storefront::createStorefrontConfig($company);
21
+ }
22
+ }
23
+ }
@@ -25,7 +25,7 @@ class EntityExpansion implements Expansion
25
25
  */
26
26
  public static function fromStorefrontProduct()
27
27
  {
28
- return static function (Product $product) {
28
+ return static function (Product $product, $meta = []) {
29
29
  return new Entity([
30
30
  'company_uuid' => session('company'),
31
31
  'photo_uuid' => $product->primary_image_uuid,
@@ -39,6 +39,7 @@ class EntityExpansion implements Expansion
39
39
  'meta' => [
40
40
  'product_id' => $product->public_id,
41
41
  'image_url' => $product->primary_image_url,
42
+ ...$meta,
42
43
  ],
43
44
  ]);
44
45
  };
@@ -19,9 +19,6 @@ class CartController extends Controller
19
19
  {
20
20
  $cart = Cart::retrieve($uniqueId, true);
21
21
 
22
- // reset currency
23
- $cart->resetCurrency();
24
-
25
22
  return new StorefrontCart($cart);
26
23
  }
27
24
 
@@ -49,9 +46,6 @@ class CartController extends Controller
49
46
  return response()->error($e->getMessage());
50
47
  }
51
48
 
52
- // reset currency
53
- $cart->resetCurrency();
54
-
55
49
  return new StorefrontCart($cart);
56
50
  }
57
51
 
@@ -80,9 +74,6 @@ class CartController extends Controller
80
74
  return response()->error($e->getMessage());
81
75
  }
82
76
 
83
- // reset currency
84
- $cart->resetCurrency();
85
-
86
77
  return new StorefrontCart($cart);
87
78
  }
88
79
 
@@ -107,9 +98,6 @@ class CartController extends Controller
107
98
  return response()->error($e->getMessage());
108
99
  }
109
100
 
110
- // reset currency
111
- $cart->resetCurrency();
112
-
113
101
  return new StorefrontCart($cart);
114
102
  }
115
103
 
@@ -264,6 +264,40 @@ class CheckoutController extends Controller
264
264
  ]);
265
265
  }
266
266
 
267
+ /**
268
+ * Process a cart item and create/save an entity.
269
+ *
270
+ * @param mixed $cartItem the cart item to process
271
+ * @param mixed $payload the payload
272
+ * @param mixed $customer the customer
273
+ *
274
+ * @return void
275
+ */
276
+ private function processCartItem($cartItem, $payload, $customer)
277
+ {
278
+ $product = Product::where('public_id', $cartItem->product_id)->first();
279
+
280
+ // Generate metas array
281
+ $metas = [
282
+ 'variants' => $cartItem->variants ?? [],
283
+ 'addons' => $cartItem->addons ?? [],
284
+ 'subtotal' => $cartItem->subtotal,
285
+ 'quantity' => $cartItem->quantity,
286
+ 'scheduled_at' => $cartItem->scheduled_at ?? null,
287
+ ];
288
+
289
+ // Create and fill entity
290
+ $entity = Entity::fromStorefrontProduct($product, $metas)->fill([
291
+ 'company_uuid' => session('company'),
292
+ 'payload_uuid' => $payload->uuid,
293
+ 'customer_uuid' => $customer->uuid,
294
+ 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
295
+ ]);
296
+
297
+ // Save entity
298
+ $entity->save();
299
+ }
300
+
267
301
  public function captureOrder(CaptureOrderRequest $request)
268
302
  {
269
303
  $token = $request->input('token');
@@ -458,10 +492,7 @@ class CheckoutController extends Controller
458
492
 
459
493
  // create entities
460
494
  foreach ($cart->items as $cartItem) {
461
- $product = Product::where('public_id', $cartItem->product_id)->first();
462
- $entity = Entity::fromStorefrontProduct($product);
463
-
464
- $entity->save();
495
+ $this->processCartItem($cartItem, $payload, $customer);
465
496
  }
466
497
 
467
498
  // create order meta
@@ -515,8 +546,6 @@ class CheckoutController extends Controller
515
546
  // create order
516
547
  $order = Order::create($orderInput);
517
548
 
518
- info('Order created', $order->toArray());
519
-
520
549
  // notify order creation
521
550
  Storefront::alertNewOrder($order);
522
551
 
@@ -692,22 +721,7 @@ class CheckoutController extends Controller
692
721
 
693
722
  // create entities
694
723
  foreach ($cartItems as $cartItem) {
695
- $product = Product::where('public_id', $cartItem->product_id)->first();
696
-
697
- $entity = Entity::fromStorefrontProduct($product)->fill([
698
- 'company_uuid' => $store->company_uuid,
699
- 'payload_uuid' => $payload->uuid,
700
- 'customer_uuid' => $customer->uuid,
701
- 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
702
- ])->setMetas([
703
- 'variants' => $cartItem->variants,
704
- 'addons' => $cartItem->addons,
705
- 'subtotal' => $cartItem->subtotal,
706
- 'quantity' => $cartItem->quantity,
707
- 'scheduled_at' => $cartItem->scheduled_at ?? null,
708
- ]);
709
-
710
- $entity->save();
724
+ $this->processCartItem($cartItem, $payload, $customer);
711
725
  }
712
726
 
713
727
  // get order subtotal
@@ -797,22 +811,7 @@ class CheckoutController extends Controller
797
811
 
798
812
  // create entities
799
813
  foreach ($cart->items as $cartItem) {
800
- $product = Product::where('public_id', $cartItem->product_id)->first();
801
-
802
- $entity = Entity::fromStorefrontProduct($product)->fill([
803
- 'company_uuid' => session('company'),
804
- 'payload_uuid' => $payload->uuid,
805
- 'customer_uuid' => $customer->uuid,
806
- 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
807
- ])->setMetas([
808
- 'variants' => $cartItem->variants,
809
- 'addons' => $cartItem->addons,
810
- 'subtotal' => $cartItem->subtotal,
811
- 'quantity' => $cartItem->quantity,
812
- 'scheduled_at' => $cartItem->scheduled_at ?? null,
813
- ]);
814
-
815
- $entity->save();
814
+ $this->processCartItem($cartItem, $payload, $customer);
816
815
  }
817
816
 
818
817
  // prepare master order meta
@@ -5,11 +5,11 @@ namespace Fleetbase\Storefront\Http\Controllers\v1;
5
5
  use Fleetbase\FleetOps\Http\Resources\v1\ServiceQuote as ServiceQuoteResource;
6
6
  use Fleetbase\FleetOps\Models\Entity;
7
7
  use Fleetbase\FleetOps\Models\IntegratedVendor;
8
+ use Fleetbase\FleetOps\Models\OrderConfig;
8
9
  use Fleetbase\FleetOps\Models\Place;
9
10
  use Fleetbase\FleetOps\Models\ServiceQuote;
10
11
  use Fleetbase\FleetOps\Models\ServiceQuoteItem;
11
12
  use Fleetbase\FleetOps\Models\ServiceRate;
12
- use Fleetbase\FleetOps\Support\Flow;
13
13
  use Fleetbase\FleetOps\Support\Utils;
14
14
  use Fleetbase\Http\Controllers\Controller;
15
15
  use Fleetbase\Storefront\Http\Requests\GetServiceQuoteFromCart;
@@ -100,12 +100,11 @@ class ServiceQuoteController extends Controller
100
100
  $serviceQuotes = collect();
101
101
 
102
102
  // get order configurations for ecommerce / task
103
- $orderConfigs = Flow::queryOrderConfigurations(function (&$query) use ($config) {
104
- $query->where('key', $config);
105
- });
103
+ $orderConfig = OrderConfig::resolveFromIdentifier($config);
104
+ $orderConfigKey = data_get($orderConfig, 'key', 'storefront');
106
105
 
107
106
  // get service rates for config type
108
- $serviceRates = ServiceRate::whereIn('service_type', $orderConfigs->pluck('key'))->get();
107
+ $serviceRates = ServiceRate::where('service_type', $orderConfigKey)->get();
109
108
 
110
109
  // if no service rates send an empty quote
111
110
  if ($serviceRates->isEmpty()) {
@@ -289,12 +288,11 @@ class ServiceQuoteController extends Controller
289
288
  $serviceQuotes = collect();
290
289
 
291
290
  // get order configurations for ecommerce / task
292
- $orderConfigs = Flow::queryOrderConfigurations(function (&$query) use ($config) {
293
- $query->where('key', $config);
294
- });
291
+ $orderConfig = OrderConfig::resolveFromIdentifier($config);
292
+ $orderConfigKey = data_get($orderConfig, 'key', 'storefront');
295
293
 
296
294
  // get service rates for config type
297
- $serviceRates = ServiceRate::whereIn('service_type', $orderConfigs->pluck('key'))->get();
295
+ $serviceRates = ServiceRate::where('service_type', $orderConfigKey)->get();
298
296
 
299
297
  // if no service rates send an empty quote
300
298
  if ($serviceRates->isEmpty()) {
@@ -37,6 +37,7 @@ class Network extends FleetbaseResource
37
37
  'tags' => $this->tags ?? [],
38
38
  'currency' => $this->currency ?? 'USD',
39
39
  'options' => $this->options ?? [],
40
+ 'alertable' => $this->alertable,
40
41
  'logo_url' => $this->logo_url,
41
42
  'backdrop_url' => $this->backdrop_url,
42
43
  'rating' => $this->rating,
@@ -41,6 +41,7 @@ class Store extends FleetbaseResource
41
41
  'backdrop_url' => $this->backdrop_url,
42
42
  'rating' => $this->rating,
43
43
  'online' => $this->online,
44
+ 'alertable' => $this->alertable,
44
45
  'is_network' => false,
45
46
  'is_store' => true,
46
47
  'category' => $this->when($request->filled('network') && ($request->has('with_category') || $request->inArray('with', 'category')), new Category($this->getNetworkCategoryUsingId($request->input('network')))),
@@ -334,6 +334,8 @@ class Cart extends StorefrontModel
334
334
  'addons' => $addons,
335
335
  ];
336
336
 
337
+ $this->updateCurrency($product->currency, false);
338
+
337
339
  foreach ($properties as $prop => $value) {
338
340
  $cartItem->{$prop} = $value;
339
341
  }
@@ -598,16 +600,6 @@ class Cart extends StorefrontModel
598
600
  return $this;
599
601
  }
600
602
 
601
- /**
602
- * Reset the cart currency code to the current session.
603
- *
604
- * @return \Fleetbase\Models\Storefront\Cart
605
- */
606
- public function resetCurrency()
607
- {
608
- return $this->updateCurrency(null, true);
609
- }
610
-
611
603
  /**
612
604
  * Creates a new cart.
613
605
  *
@@ -679,6 +671,6 @@ class Cart extends StorefrontModel
679
671
  */
680
672
  public static function findProduct(string $id): ?Product
681
673
  {
682
- return Product::select(['uuid', 'store_uuid', 'public_id', 'name', 'description', 'price', 'sale_price', 'is_on_sale'])->where(['public_id' => $id])->with([])->first();
674
+ return Product::select(['uuid', 'store_uuid', 'public_id', 'name', 'description', 'price', 'currency', 'sale_price', 'is_on_sale'])->where(['public_id' => $id])->with([])->first();
683
675
  }
684
676
  }
@@ -322,9 +322,6 @@ class Product extends StorefrontModel
322
322
  'max_selectable' => data_get($addonCategory, 'max_selectable'),
323
323
  'is_required' => data_get($addonCategory, 'is_required'),
324
324
  ]);
325
-
326
- // insert to hasmany relation
327
- $this->addonCategories->push($productAddonCategory);
328
325
  }
329
326
 
330
327
  return $this;
@@ -357,8 +354,8 @@ class Product extends StorefrontModel
357
354
  'meta' => data_get($variant, 'meta', []),
358
355
  'is_multiselect' => data_get($variant, 'is_multiselect'),
359
356
  'is_required' => data_get($variant, 'is_required'),
360
- 'min' => data_get($variant, 'min'),
361
- 'max' => data_get($variant, 'max'),
357
+ 'min' => data_get($variant, 'min') ?? 0,
358
+ 'max' => data_get($variant, 'max') ?? 100,
362
359
  ]);
363
360
 
364
361
  // Update product variant options if applicable
@@ -0,0 +1,20 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Observers;
4
+
5
+ use Fleetbase\Models\Company;
6
+ use Fleetbase\Storefront\Support\Storefront;
7
+
8
+ class CompanyObserver
9
+ {
10
+ /**
11
+ * Handle the Company "created" event.
12
+ *
13
+ * @return void
14
+ */
15
+ public function created(Company $company)
16
+ {
17
+ // Add the default storefront order config
18
+ Storefront::createStorefrontConfig($company);
19
+ }
20
+ }
@@ -27,7 +27,7 @@ class NetworkObserver
27
27
  return [
28
28
  $key => collect($alertables)->map(
29
29
  function ($user) {
30
- return data_get($user, 'public_id');
30
+ return $user;
31
31
  }
32
32
  )
33
33
  ->values()
@@ -26,6 +26,7 @@ class StorefrontServiceProvider extends CoreServiceProvider
26
26
  public $observers = [
27
27
  \Fleetbase\Storefront\Models\Product::class => \Fleetbase\Storefront\Observers\ProductObserver::class,
28
28
  \Fleetbase\Storefront\Models\Network::class => \Fleetbase\Storefront\Observers\NetworkObserver::class,
29
+ \Fleetbase\Models\Company::class => \Fleetbase\Storefront\Observers\CompanyObserver::class,
29
30
  ];
30
31
 
31
32
  /**