Skip to content

Commit

Permalink
Fix(useCart): canAddToCart not working correctly
Browse files Browse the repository at this point in the history
Check if `stock_status` is 'IN_STOCK' or 'OUT_OF_STOCK'. 

vuestorefront#1416
  • Loading branch information
bensinca authored Feb 6, 2023
1 parent db2f054 commit 5c87d85
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/theme/modules/checkout/composables/useCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useWishlist } from '~/modules/wishlist/composables/useWishlist';
import { Product } from '~/modules/catalog/product/types';
import { ComposableFunctionArgs } from '~/composables';
import { UseCartErrors, UseCartInterface } from './useCart';
import { ProductStockStatus } from '~/modules/GraphQL/types';

/**
* Allows loading and manipulating cart of the current user.
Expand Down Expand Up @@ -272,7 +273,7 @@ PRODUCT
return !!product?.configurable_product_options_selection?.variant
?.uid;
}
const inStock = product?.stock_status || '';
const inStock = product.stock_status === ProductStockStatus.InStock ? true : false;
const stockLeft = product?.only_x_left_in_stock === null
? true
: qty <= product?.only_x_left_in_stock;
Expand Down

0 comments on commit 5c87d85

Please sign in to comment.