4
0
forked from crowetic/commerce
commerce/framework/shopify/cart/use-remove-item.tsx
Peter Mekhaeil 300d04c1ac
Shopify Provider (#186)
* Start of Shopify provider

* add missing comment to documentation

* add missing env vars to documentation

* update reference to types file
2021-02-12 11:14:16 -03:00

18 lines
434 B
TypeScript

import { useCallback } from 'react'
import { useCommerce } from '../index'
const useRemoveItem = () => {
const { checkout, client, updateCheckout } = useCommerce()
return useCallback(
async function removeItem({ id }: { id: string }) {
const cart = await client?.checkout.removeLineItems(checkout.id, [id])
updateCheckout(cart)
return cart
},
[checkout, client]
)
}
export default useRemoveItem