Feat: Hiding unused shipping types and removing unused fulfillment types

This commit is contained in:
2026-09-29 00:43:48 +03:00
parent d6c6bf6a1c
commit 359b645c62
7 changed files with 46 additions and 133 deletions
+15 -15
View File
@@ -60,16 +60,6 @@ class ShippingServiceProvider extends ServiceProvider
// first load, the Livewire registration covers every AJAX
// round-trip (form submits, table interactions) afterwards.
$this->app->bind(VendorManageShippingRates::class, ManageShippingRates::class);
// Binds AFTER the vendor's own ShippingServiceProvider — the
// last-registered bind() for a given abstract wins in Laravel's
// container, and vendor providers register before this one lists
// theirs as a dependency implicitly via composer.json's package
// discovery order — see Modules\Core\Shipping\Support\
// ShippingManager's own docblock for why this override exists at
// all (dropping the vendor's generic drivers from
// getSupportedDrivers()).
$this->app->bind(ShippingMethodManagerInterface::class, fn ($app) => $app->make(ShippingManager::class));
}
public function boot(): void
@@ -94,10 +84,9 @@ class ShippingServiceProvider extends ServiceProvider
// resolveCarrier() for the same lookup pattern already used to
// resolve a carrier driver from it).
//
// Resolves via Modules\Core\Shipping\Support\FulfillmentType (driver-
// declared for acs/box-now, merchant-configured data['fulfillment_type']
// fallback for table-rate-shipping's generic drivers) rather than
// through a ShippingMethod::macro('isStorePickup', ...) —
// Resolves via Modules\Core\Shipping\Support\FulfillmentType
// (hardcoded per driver — see that class's own docblock) rather
// than through a ShippingMethod::macro('isStorePickup', ...) —
// Lunar\Base\Traits\HasModelExtending::__callStatic() (used by
// Lunar\Shipping\Models\ShippingMethod via Lunar\Base\BaseModel)
// intercepts EVERY unmatched static call, including macro()
@@ -132,8 +121,19 @@ class ShippingServiceProvider extends ServiceProvider
// Deferred: the Shipping facade resolves a binding registered in
// lunarphp/table-rate-shipping's own ShippingServiceProvider::boot(),
// and provider boot order between packages isn't guaranteed.
// and provider boot order between packages isn't guaranteed — in
// fact composer's package discovery registers boboko/core BEFORE
// lunarphp/table-rate-shipping (alphabetical), so a bind() in this
// provider's own register()/boot() runs first and gets silently
// overwritten by the vendor's own later bind() of the same
// abstract. booted() is the first point every provider's
// register()/boot() has definitely already run, so this is also
// where the ShippingMethodManagerInterface override belongs (must
// run before the Shipping::extend() calls below, which resolve —
// and the facade then CACHES — whatever's bound at that moment).
$this->app->booted(function () {
$this->app->bind(ShippingMethodManagerInterface::class, fn ($app) => $app->make(ShippingManager::class));
Shipping::extend('acs', fn ($app) => $app->make(AcsRateDriver::class));
Shipping::extend('box-now', fn ($app) => $app->make(BoxNowRateDriver::class));
Shipping::extend('store-pickup', fn ($app) => $app->make(StorePickupRateDriver::class));