Fix: Correct shipment resolving
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?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
|
||||
* ShippingServiceProvider — see that class for why (registration order:
|
||||
* this module's provider binds after the vendor's own).
|
||||
*/
|
||||
class ShippingManager extends VendorShippingManager
|
||||
{
|
||||
public function getSupportedDrivers(): \Illuminate\Support\Collection
|
||||
{
|
||||
return collect($this->customCreators)
|
||||
->mapWithKeys(function ($creator, $key) {
|
||||
return [$key => $this->callCustomCreator($key)];
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user