Check stock for Shop's add to cart button
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
export let product: any
|
||||
export let shopProduct: any
|
||||
|
||||
$: hasStock = shopProduct.stock_level > 0
|
||||
|
||||
|
||||
/**
|
||||
* Preview photos specs
|
||||
@@ -69,8 +71,10 @@
|
||||
<dd>{shopProduct.name} – {shopProduct.price}€</dd>
|
||||
</dl>
|
||||
<Button
|
||||
text="Add to cart"
|
||||
tag="button"
|
||||
text={hasStock ? 'Add to cart' : 'Sold out'}
|
||||
color="pinklight"
|
||||
disabled={!hasStock}
|
||||
on:click={() => addToCart($cartId, shopProduct)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user