---
title: Interface: UseProduct
slug: chord-ui/interface-useproduct
docTags: 
createdAt: 2023-11-06T15:03:31.906Z
---

[react-autonomy](docId\:zoZ6W56ubpPACr0PO0GLS).UseProduct

`UseProduct` contains the data and methods returned by the [useProduct](docId\:SsZ9tBKbUCNvACA1XNZx0)
hook.

## Properties

### createStockRequest

• **createStockRequest**: (`options`: [`CreateStockRequest`](docId\:UcZXJnkxjH0yRhCLXcaO7)) => `Promise`\<`void`>

### Type declaration

▸ (`options`): `Promise`\<`void`>

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.



```javascript
import { useProduct } from '@chordcommerce/react-autonomy'

const NotifyWhenBackInStockButton = ({ email, product }) => {
  const { createStockRequest } = useProduct()

  const onClick = () => createStockRequest({ email, product })

  return <button onClick={onClick}>Notify</button>
}
```

### Parameters

| Name      | Type                                                 |
| --------- | ---------------------------------------------------- |
| `options` | [`CreateStockRequest`](docId\:UcZXJnkxjH0yRhCLXcaO7) |

### Returns

`Promise`\<`void`>

A Promise that resolves when the stock request has been created.

### Defined in

[packages/react-autonomy/src/hooks/use-product.ts:88](https://github.com/chordcommerce/chord-ui/blob/2b105e1/packages/react-autonomy/src/hooks/use-product.ts#L88)

***

### getPrice

• **getPrice**: (`input`: [`VariantPriceInput`](docId\:Ad8K-A9KluEqhYP37vUKC)) => `Promise`\<[`VariantPrice`](docId\:PSTuVNYFy8TjU_zbZncoY)>

### Type declaration

▸ (`input`): `Promise`\<[`VariantPrice`](docId\:PSTuVNYFy8TjU_zbZncoY)>

The `getPrice` method returns the price (including discount if applicable)
for a produuct's variant by providing a SKU.



```javascript
import { useProduct, useCart } from '@chordcommerce/react-autonomy'
import { useState, useEffect } from 'react'

const BuyNowButton = ({ sku }) => {
  const { getPrice } = useProduct()
  const { addToCart } = useCart()
  const [price, setPrice] = useState()

  useEffect(() => {
    getPrice({ sku }).then(data => {
      setPrice(data)
    })
  }, [getPrice, sku])

  return (
    <>
      <div><>{price.price}</div>
      <div><>{price.discountPrice}</div>
    </>
  )
}
```

### Parameters

| Name    | Type                                                |
| ------- | --------------------------------------------------- |
| `input` | [`VariantPriceInput`](docId\:Ad8K-A9KluEqhYP37vUKC) |

### Returns

`Promise`\<[`VariantPrice`](docId\:PSTuVNYFy8TjU_zbZncoY)>

A Promise that resolves with the price of the SKU.

### Defined in

[packages/react-autonomy/src/hooks/use-product.ts:158](https://github.com/chordcommerce/chord-ui/blob/2b105e1/packages/react-autonomy/src/hooks/use-product.ts#L158)

***

### getStockAvailability

• **getStockAvailability**: (`input`: [`VariantStockAvailabilityInput`](docId\:DDphY6CMTuDBNf2JP3dqI)) => `Promise`\<[`VariantStockAvailability`](docId:2TE_Ia0GfoQw92poBunXU)>

### Type declaration

▸ (`input`): `Promise`\<[`VariantStockAvailability`](docId:2TE_Ia0GfoQw92poBunXU)>

The `getStockAvailability` method returns the stock availability for
a produuct's variant by providing a SKU.



```javascript
import { useProduct, useCart } from '@chordcommerce/react-autonomy'
import { useState, useEffect } from 'react'

const BuyNowButton = ({ sku }) => {
  const { getStockAvailability } = useProduct()
  const { addToCart } = useCart()
  const [inStock, setInStock] = useState(false)

  useEffect(() => {
    getStockAvailability({ sku }).then(availability => {
      setInStock(availability.inStock)
    })
  }, [getStockAvailability, sku])

  return (
    <button
      onClick={() => addToCart({ sku, quantity: 1 })}
      disabled={!inStock}
    >
      Buy Now!
    </button>
  )
}
```

### Parameters

| Name    | Type                                                            |
| ------- | --------------------------------------------------------------- |
| `input` | [`VariantStockAvailabilityInput`](docId\:DDphY6CMTuDBNf2JP3dqI) |

### Returns

`Promise`\<[`VariantStockAvailability`](docId:2TE_Ia0GfoQw92poBunXU)>

A Promise that resolves with the stock availability of the SKU.

### Defined in

[packages/react-autonomy/src/hooks/use-product.ts:123](https://github.com/chordcommerce/chord-ui/blob/2b105e1/packages/react-autonomy/src/hooks/use-product.ts#L123)
