Skip to content

Commit

Permalink
Hotfix - Fix discount saving (#793)
Browse files Browse the repository at this point in the history
* Fix switching to discount type

* Fixes #791

* Update show.blade.php
  • Loading branch information
alecritson authored Jan 11, 2023
1 parent 2f4de72 commit 42af3ad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class="w-8 h-8" />
{{ $discount->name }}
</h1>
</div>

<form action="#"
method="POST"
wire:submit.prevent="save">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,15 @@ public function syncAvailability()
];
}),
'customerGroups' => $this->customerGroups->mapWithKeys(function ($group) {
// $productGroup = $this->product->customerGroups->where('id', $group->id)->first();
$discountGroup = $this->discount->customerGroups->where('id', $group->id)->first();

// $pivot = $productGroup->pivot ?? null;

$pivot = null;
$pivot = $discountGroup->pivot ?? null;

return [
$group->id => [
'customer_group_id' => $group->id,
'scheduling' => false,
'enabled' => false,
'enabled' => $pivot?->enabled ?? false,
'status' => 'hidden',
'starts_at' => $pivot?->starts_at ?? null,
'ends_at' => $pivot?->ends_at ?? null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function rules()
'discount.data' => 'array',
'discount.data.percentage' => 'required_if:discount.data.fixed_value,false|nullable|numeric|min:1',
'discount.data.fixed_values' => 'array|min:0',
'discount.data.fixed_value' => 'boolean',
'discount.data.fixed_value' => 'nullable|boolean',
];

foreach ($this->currencies as $currency) {
Expand Down

0 comments on commit 42af3ad

Please sign in to comment.