Skip to content

Commit

Permalink
Merge pull request #72 from shopgate/PWA-437-add-product-stock-info-s…
Browse files Browse the repository at this point in the history
…electors

PWA-437: Favourite list has issues with "out of stock" items
  • Loading branch information
devbucket authored May 28, 2018
2 parents b5ad528 + 1a95bb3 commit 15f3947
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions libraries/commerce/product/selectors/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,21 @@ export const getCurrentProductStock = createSelector(
}
);

/**
* Retrieves the product stock information.
* @param {Object} state The current application state.
* @return {Object|null}
*/
export const getProductStockInfo = createSelector(
getProductById,
(product) => {
if (!product || !product.productData) {
return null;
}
return product.productData.stock;
}
)

/**
* Retrieves the current product orderable information.
* @param {Object} state The current application state.
Expand All @@ -326,6 +341,16 @@ export const isProductOrderable = createSelector(
}
);

/**
* Retrieves the product orderable information.
* @param {Object} state The current application state.
* @return {boolean}
*/
export const isOrderable = createSelector(
getProductStockInfo,
stockInfo => stockInfo && stockInfo.orderable
);

/**
* Selects the product shipping state.
* @param {Object} state The current application state.
Expand Down

0 comments on commit 15f3947

Please sign in to comment.