mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 23:46:58 +00:00
pass pricing to addItem call for verification and update cart API URL
Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
parent
c2c43b76aa
commit
4d48c511ca
@ -29,9 +29,16 @@ const ProductSidebar: FC<ProductSidebarProps> = ({ product, className }) => {
|
||||
const addToCart = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
console.log("product", product)
|
||||
console.log("variant", variant)
|
||||
|
||||
await addItem({
|
||||
productId: String(product.id),
|
||||
variantId: String(variant ? variant.id : product.variants[0].id),
|
||||
pricing: {
|
||||
amount: variant ? Number.parseFloat(variant.price) : Number.parseFloat(product.price.value),
|
||||
currencyCode: String(product.price.currencyCode),
|
||||
}
|
||||
})
|
||||
openSidebar()
|
||||
setLoading(false)
|
||||
|
@ -43,6 +43,7 @@ const addItem: CartEndpoint['handlers']['addItem'] = async ({
|
||||
if (!item.quantity) item.quantity = 1
|
||||
|
||||
if (cartId === config.dummyEmptyCartId) {
|
||||
console.log("pricing", item.pricing)
|
||||
const createdCart = await config.fetch(createCartMutation, {
|
||||
variables: {
|
||||
input: {
|
||||
|
@ -9,7 +9,7 @@ export default useAddItem as UseAddItem<typeof handler>
|
||||
|
||||
export const handler: MutationHook<Cart, {}, CartItemBody> = {
|
||||
fetchOptions: {
|
||||
url: '/api/reactioncommerce/cart',
|
||||
url: '/api/cart',
|
||||
method: 'POST',
|
||||
},
|
||||
async fetcher({ input: item, options, fetch }) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user