Skip to content

Commit

Permalink
fix: invoice clear cart (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and libruce committed Feb 7, 2024
1 parent cb2ac11 commit d1c35ea
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apps/storefront/src/utils/b3ClearCart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@ const clearInvoiceCart = async () => {
const cartInfo = cartEntityId
? await getCart(cartEntityId, platform)
: null

if (cartInfo) {
const deleteQuery = deleteCartData(cartEntityId)
let newCartId = cartEntityId
if (cartInfo?.data && cartInfo?.data?.site) {
const { cart } = cartInfo.data.site
newCartId = cart?.entityId || cartEntityId
}

const deleteQuery = deleteCartData(newCartId)
await deleteCart(deleteQuery)
localStorage.removeItem('invoicePay')
store.dispatch(setCartNumber(0))
const cartNumberDom = document.querySelector(
'.cart-quantity.countPill--positive'
)
if (cartNumberDom) {
cartNumberDom.className = 'countPill cart-quantity'
}
}
}
} catch (err) {
Expand Down

0 comments on commit d1c35ea

Please sign in to comment.