Check stock for Shop's add to cart button

This commit is contained in:
2021-11-20 21:39:44 +01:00
parent 4ee17f921e
commit 6559298212
2 changed files with 8 additions and 4 deletions

View File

@@ -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>