Skip to content

Commit

Permalink
Fix bad merge on discount limitations (#1332)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell authored Nov 10, 2023
1 parent 5301024 commit 6060b23
Showing 1 changed file with 0 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,6 @@ public function mount()
->map(function ($limitation) {
return array_merge($this->mapProductVariantToArray($limitation->purchasable), ['type' => $limitation->type]);
});

$this->selectedProductVariants = $this->discount->purchasableLimitations()
->wherePurchasableType(ProductVariant::class)
->get()
->map(function ($limitation) {
return $this->mapProductVariantToArray($limitation->purchasable);
});

$this->selectedConditions = $this->discount->purchasableConditions()
->wherePurchasableType(Product::class)
Expand Down Expand Up @@ -454,20 +447,6 @@ public function save()
])
->save();
}

$this->discount->purchasableLimitations()
->where('purchasable_type', ProductVariant::class)
->whereNotIn('purchasable_id', $this->selectedProductVariants->pluck('id'))
->delete();

foreach ($this->selectedProductVariants as $variant) {
$this->discount->purchasableLimitations()->firstOrCreate([
'discount_id' => $this->discount->id,
'type' => 'limitation',
'purchasable_type' => ProductVariant::class,
'purchasable_id' => $variant['id'],
]);
}
});

$this->emit('discount.saved', $this->discount->id);
Expand Down

1 comment on commit 6060b23

@vercel
Copy link

@vercel vercel bot commented on 6060b23 Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.