Interfaces
Interface: UseProduct
module react autonomy docid\ zoz6w56ubppacr0po0gls useproduct useproduct contains the data and methods returned by the function useproduct docid\ ssz9tbkbucnvaca1xnzx0 hook properties createstockrequest • createstockrequest ( options interface 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 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 interface 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 interface variantpriceinput docid\ ad8k a9klueqhyp37vukc ) => promise < interface variantprice docid\ pstuvnyfy8tju zbzncoy > type declaration ▸ ( input ) promise < interface variantprice docid\ pstuvnyfy8tju zbzncoy > the getprice method returns the price (including discount if applicable) for a produuct's variant by providing a sku 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 interface variantpriceinput docid\ ad8k a9klueqhyp37vukc returns promise < interface 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 interface variantstockavailabilityinput docid\ ddphy6cmtudbnf2jp3dqi ) => promise < interface variantstockavailability docid 2te ia0gfoqw92pobunxu > type declaration ▸ ( input ) promise < interface variantstockavailability docid 2te ia0gfoqw92pobunxu > the getstockavailability method returns the stock availability for a produuct's variant by providing a sku 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 interface variantstockavailabilityinput docid\ ddphy6cmtudbnf2jp3dqi returns promise < interface 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