useProduct
This page's documentation only applies to Chord's Next.js starter prior to the release of the React. The Next.js starter now uses the React SDK and does not use the methods documented on this page. Check out the React SDK Reference for complete documentation, and the React SDK Migration Guidefor details on how to upgrade.
The useProduct hook returns a set of functions for product-related operations.
Example
import { useProduct } from '~/hooks/actions'
// inside a function component
const { createStockRequest } = useProduct()Returns
The useProduct hook returns an object with these properties:
Property | Description |
|---|---|
createStockRequest | |
Functions
createStockRequest
The createStockRequest adds the customer to a product variant wait list in the OMS. When the variant is marked back in stock, customers on the wait list will automatically receive an email notification.
Arguments:
createStockRequest(options)
Argument | Type | Description |
|---|---|---|
options.email | String | The email address to sent an email to when the variant is back in stock. |
options.sku | String | The variant SKU. |
options.slug | String | For kits only, the slug of the kit. |
Returns:
Promise<void>: A Promise that resolves when the stock request has been created.
Example:
import { useProduct } from '~/hooks/actions'
export default () => {
const { createStockRequest } = useProduct()
await createStockRequest({ email, sku })
}