Skip to content

Commit

Permalink
PWA-437: Favourite list has issues with "out of stock" items
Browse files Browse the repository at this point in the history
- add product stock info selectors
  • Loading branch information
Carina Hoffmann committed May 28, 2018
1 parent a86ee7e commit 1064bac
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 1064bac

Please sign in to comment.