Feature: Minor Updates to Order Shipping And Order Statuses

This commit is contained in:
2026-09-10 22:50:40 +03:00
parent 99e55902ac
commit 78bbd8390a
8 changed files with 207 additions and 5 deletions
+25
View File
@@ -69,6 +69,31 @@ class ShippingServiceProvider extends ServiceProvider
return $order->hasMany(Shipment::class);
});
// ShippingMethod.data['fulfillment_type'] — see
// ShippingMethodResourceExtension::fulfillmentTypeSelect() for
// where it's set. Defaults to 'carrier' (false here) for any row
// saved before this field existed.
ShippingMethod::macro('isStorePickup', function () {
/** @var ShippingMethod $this */
return ($this->data['fulfillment_type'] ?? 'carrier') === 'store_pickup';
});
// Order has no direct ShippingMethod relation — shippingAddress.
// shipping_option is only ever a code string (see
// Modules\Core\Shipping\Extensions\OrderViewExtension::
// resolveCarrier() for the same lookup pattern already used to
// resolve a carrier driver from it).
Order::macro('isStorePickupOrder', function () {
/** @var Order $this */
$code = $this->shippingAddress?->shipping_option;
if (! $code) {
return false;
}
return ShippingMethod::where('code', $code)->first()?->isStorePickup() ?? false;
});
foreach ([CartLineAdded::class, CartLineUpdated::class, CartLineRemoved::class, CartCleared::class, ShippingAddressSet::class] as $event) {
Event::listen($event, [InvalidateShippingOptions::class, 'handle']);
}