forked from crowetic/commerce
* Start of Shopify provider * add missing comment to documentation * add missing env vars to documentation * update reference to types file
43 lines
943 B
TypeScript
43 lines
943 B
TypeScript
import { useCommerce } from '../index'
|
|
|
|
export function emptyHook() {
|
|
const { checkout } = useCommerce()
|
|
const { lineItems, totalPriceV2 } = checkout || {}
|
|
|
|
return {
|
|
data: {
|
|
subTotal: totalPriceV2?.amount || 0,
|
|
total: totalPriceV2?.amount || 0,
|
|
currency: {
|
|
code: '',
|
|
},
|
|
line_items:
|
|
lineItems?.map((item) => {
|
|
return [
|
|
{
|
|
id: item.id,
|
|
name: item.title,
|
|
quantity: item.quantity,
|
|
},
|
|
]
|
|
}) || [],
|
|
items:
|
|
lineItems?.map((item) => {
|
|
return {
|
|
id: item.id,
|
|
name: item.title,
|
|
images: [{ url: '/jacket.png' }],
|
|
url: '/',
|
|
quantity: item.quantity,
|
|
productId: item.id,
|
|
variantId: item.id,
|
|
}
|
|
}) || [],
|
|
},
|
|
isEmpty: false,
|
|
isLoading: false,
|
|
}
|
|
}
|
|
|
|
export default emptyHook
|