Skip to content

Commit

Permalink
Allow a quantity of 0 on a wishlist item (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jade-GG authored Mar 15, 2024
1 parent 96a7f69 commit ea37532
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions resources/js/Wishlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export default {
},
async addToCart(item) {
if (item.qty <= 0) {
return
}
await this.magentoCart('post', 'items', {
cartItem: {
sku: item.product.sku,
Expand Down
4 changes: 2 additions & 2 deletions resources/js/WishlistItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default {
return
}
if(newVal < this.product.min_sale_qty) {
this.quantity = this.product.min_sale_qty
if(newVal < 0) {
this.quantity = 0
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="flex w-20 overflow-hidden rounded border">
<button
@disabled(!$editable)
v-bind:disabled="self.quantity - 1 < product.min_sale_qty"
v-bind:disabled="self.quantity <= 0"
class="flex-1 bg-ct-inactive-100 transition hover:bg-opacity-80"
v-on:click="self.quantity--"
>-</button>
Expand All @@ -13,7 +13,7 @@ class="h-10 w-2/5 border-none px-0 text-center text-sm [appearance:textfield] fo
{{ $attributes }}
@disabled(!$editable)
v-model="self.quantity"
v-bind:min="product.min_sale_qty"
min="0"
v-bind:step="product.qty_increments"
/>
<button
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/WishlistItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function update(Request $request, WishlistItem $item)
{
$validated = $request->validate([
'description' => 'nullable|string|max:255',
'qty' => 'integer|min:1'
'qty' => 'integer|min:0'
]);

$item->rapidezWishlist()->firstOrFail();
Expand Down

0 comments on commit ea37532

Please sign in to comment.