From 637c22f1886cecf7307ced88dc951134d466a3fa Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 19 Jun 2023 15:46:03 +0700 Subject: checkout --- src/core/utils/cart.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/core/utils') diff --git a/src/core/utils/cart.js b/src/core/utils/cart.js index ad7894b5..6575f6d0 100644 --- a/src/core/utils/cart.js +++ b/src/core/utils/cart.js @@ -14,13 +14,6 @@ const getCart = () => { return {} } -const getCartnew = async () => { - const id = getAuth()?.id - const cart = await odooApi('GET', `/api/v1/user/${id}/cart`) - - return cart -} - /** * Saves cart data to localStorage, if available. * @@ -51,6 +44,22 @@ const addCart = async (product_id, qty, selected) => { ) } +const getCartApi = async () => { + const id = getAuth()?.id + const cart = await odooApi('GET', `/api/v1/user/${id}/cart`) + + return cart +} + +const getCountCart = async () => { + const id = getAuth()?.id + if(id){ + const cart = await odooApi('GET', `/api/v1/user/${id}/cart/count`) + return cart + } + return +} + const deleteCart = async (product_id) => { const id = getAuth()?.id const cartDelete = await odooApi( @@ -85,7 +94,7 @@ const updateItemCart = ({ productId, quantity, selected = false }) => { quantity = parseInt(quantity) cart[productId] = { productId, quantity, selected } setCart(cart) - addCart(productId, quantity) + addCart(productId, quantity, selected) return true } @@ -104,4 +113,4 @@ const deleteItemCart = ({ productId }) => { return true } -export { getCart, getItemCart, updateItemCart, deleteItemCart, getCartnew } +export { getCart, getItemCart, updateItemCart, deleteItemCart, addCart, getCartApi, getCountCart} -- cgit v1.2.3