2026-09-29 00:35:29 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Modules\Core\Shipping\Support;
|
|
|
|
|
|
|
|
|
|
use Lunar\Shipping\Managers\ShippingManager as VendorShippingManager;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Drops lunarphp/table-rate-shipping's own generic drivers (free-shipping,
|
|
|
|
|
* flat-rate, ship-by, collection) from getSupportedDrivers() — every
|
|
|
|
|
* shipping method in this app now uses a first-party driver (ACS, Box
|
|
|
|
|
* Now, or Modules\Core\Shipping\Carriers\StorePickup\StorePickupRateDriver,
|
|
|
|
|
* registered via Shipping::extend() in ShippingServiceProvider), each of
|
|
|
|
|
* which declares its own fulfillment type and correctly decodes
|
|
|
|
|
* ShippingMethod's translatable `name` column (see StorePickupRateDriver's
|
|
|
|
|
* own docblock for why the vendor `collection` driver specifically had to
|
|
|
|
|
* go — it read $shippingMethod->name raw, showing the storefront the raw
|
|
|
|
|
* JSON blob instead of a translated string). The generic drivers'
|
|
|
|
|
* create{X}Driver() methods still exist on the parent (harmless — nothing
|
|
|
|
|
* calls them once their key is gone from getSupportedDrivers()), so this
|
|
|
|
|
* only needs to override the one method that lists what's offered.
|
|
|
|
|
*
|
|
|
|
|
* Bound over the vendor's own ShippingMethodManagerInterface binding in
|
2026-09-29 00:43:48 +03:00
|
|
|
* ShippingServiceProvider, from inside its own $this->app->booted(...)
|
|
|
|
|
* callback — a plain register()-time bind() here runs BEFORE the
|
|
|
|
|
* vendor's own (composer discovers boboko/core before lunarphp/
|
|
|
|
|
* table-rate-shipping alphabetically), so the vendor's later bind()
|
|
|
|
|
* would silently win instead. See that provider's own comment.
|
2026-09-29 00:35:29 +03:00
|
|
|
*/
|
|
|
|
|
class ShippingManager extends VendorShippingManager
|
|
|
|
|
{
|
|
|
|
|
public function getSupportedDrivers(): \Illuminate\Support\Collection
|
|
|
|
|
{
|
|
|
|
|
return collect($this->customCreators)
|
|
|
|
|
->mapWithKeys(function ($creator, $key) {
|
|
|
|
|
return [$key => $this->callCustomCreator($key)];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|