Skip to content

Commit

Permalink
Add missing hooks to manages product pricing (#1643)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell authored Jun 5, 2024
1 parent 27ec7c5 commit 96f3735
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function form(Form $form): Form
$this->basePrices = $this->getBasePrices();
}

return $form->schema([
$form->schema([
Forms\Components\Section::make()
->schema([
Forms\Components\Group::make([
Expand All @@ -54,6 +54,10 @@ public function form(Form $form): Form
]),
$this->getBasePriceFormSection(),
])->statePath('');

$this->callLunarHook('extendForm', $form);

return $form;
}

public function getRelationManagers(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public static function getNavigationLabel(): string

protected function handleRecordUpdate(Model $record, array $data): Model
{
$data = $this->callLunarHook('beforeUpdate', $data, $record);

$variant = $this->getOwnerRecord();

$prices = collect($data['basePrices']);
Expand Down Expand Up @@ -72,7 +74,7 @@ protected function handleRecordUpdate(Model $record, array $data): Model

$this->dispatch('refresh-relation-manager');

return $record;
return $this->callLunarHook('afterUpdate', $record, $data);
}

public function getBasePriceFormSection(): Section
Expand Down Expand Up @@ -146,7 +148,7 @@ public function form(Forms\Form $form): Forms\Form
$this->basePrices = $this->getBasePrices();
}

return $form->schema([
$form->schema([
Forms\Components\Section::make()->schema([
Forms\Components\Group::make([
ProductVariantResource::getTaxClassIdFormComponent(),
Expand All @@ -155,6 +157,10 @@ public function form(Forms\Form $form): Forms\Form
]),
$this->getBasePriceFormSection(),
])->statePath('');

$this->callLunarHook('extendForm', $form);

return $form;
}

protected function getBasePrices(): array
Expand Down

0 comments on commit 96f3735

Please sign in to comment.