Feat: Shipping functionalities redesign, elta courier integration, commenting out acs since no integration can happen, flow updates
This commit is contained in:
@@ -8,6 +8,8 @@ use Filament\Schemas\Components\Concerns\HasChildComponents;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use InvalidArgumentException;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Lunar\Admin\Support\Extending\ResourceExtension;
|
||||
@@ -110,15 +112,49 @@ class ShippingMethodResourceExtension extends ResourceExtension
|
||||
}
|
||||
|
||||
if (in_array(HasChildComponents::class, class_uses_recursive($component), true)) {
|
||||
$component->schema(
|
||||
$this->replaceChargeByField($component->getDefaultChildComponents())
|
||||
$children = $this->replaceChargeByField($component->getDefaultChildComponents());
|
||||
|
||||
// The manual carrier's settings sit next to charge_by, in
|
||||
// the same `data` group.
|
||||
$hasChargeBy = collect($children)->contains(
|
||||
fn (Component $child) => method_exists($child, 'getName') && $child->getName() === 'charge_by'
|
||||
);
|
||||
|
||||
$component->schema($hasChargeBy ? [...$children, ...$this->manualCarrierFields()] : $children);
|
||||
}
|
||||
|
||||
return $component;
|
||||
}, $components);
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings for a carrier without an integration (ManualRateDriver),
|
||||
* stored in the method's `data`. Shown only for that driver.
|
||||
*
|
||||
* @return array<Component>
|
||||
*/
|
||||
private function manualCarrierFields(): array
|
||||
{
|
||||
$isManual = fn (Get $get) => $get('../driver') === 'manual';
|
||||
|
||||
return [
|
||||
TextInput::make('carrier_name')
|
||||
->label('Carrier name')
|
||||
->helperText('Shown to staff and customers on this carrier\'s shipments, e.g. "Geniki Taxydromiki".')
|
||||
->visible($isManual)
|
||||
->required($isManual),
|
||||
TextInput::make('tracking_url')
|
||||
->label('Tracking URL')
|
||||
->helperText('Optional. The carrier\'s tracking page, with {number} where the voucher number goes, e.g. https://example.com/track?number={number}.')
|
||||
->rule('starts_with:http://,https://')
|
||||
->visible($isManual),
|
||||
Toggle::make('collects_cash')
|
||||
->label('Courier collects cash on delivery')
|
||||
->helperText('Offers cash on delivery at checkout for this shipping method.')
|
||||
->visible($isManual),
|
||||
];
|
||||
}
|
||||
|
||||
private function chargeBySelect(): Select
|
||||
{
|
||||
return Select::make('charge_by')
|
||||
|
||||
Reference in New Issue
Block a user