Skip to content

Commit

Permalink
Merge pull request #2170 from graphcommerce-org/feature/GCOM-1317
Browse files Browse the repository at this point in the history
fix(GCOM-1317): fix bug where inactive cached cart could be set as currentCartId
  • Loading branch information
paales authored Jan 18, 2024
2 parents b095467 + f3e906f commit a8ca29a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/nasty-icons-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphcommerce/magento-cart": patch
"@graphcommerce/magento-customer": patch
---

fix(GCOM-1317): fix bug where inactive cached cart could be set as currentCartId
3 changes: 2 additions & 1 deletion packages/magento-cart/hooks/useMergeCustomerCart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export function useMergeCustomerCart() {
const assignCurrentCartId = useAssignCurrentCartId()
const [merge] = useMutation(UseMergeCustomerCartDocument, { errorPolicy: 'all' })

const destinationCartId = useCustomerQuery(CustomerCartDocument)?.data?.customerCart.id
const destinationCartId = useCustomerQuery(CustomerCartDocument, { fetchPolicy: 'network-only' })
?.data?.customerCart.id

useEffect(() => {
// If we don't have a customer cart, we're done
Expand Down
8 changes: 4 additions & 4 deletions packages/magento-customer/components/SignOutForm/signOut.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ApolloClient } from '@graphcommerce/graphql'

export function signOut(client: ApolloClient<object>) {
client.cache.evict({ fieldName: 'cart' })
client.cache.evict({ fieldName: 'customer' })
client.cache.evict({ fieldName: 'customerCart' })
client.cache.evict({ fieldName: 'currentCartId' })
client.cache.evict({ fieldName: 'currentCartId', broadcast: true })
client.cache.evict({ fieldName: 'cart', broadcast: true })
client.cache.evict({ fieldName: 'customerToken', broadcast: true })
client.cache.evict({ fieldName: 'customer', broadcast: true })
client.cache.evict({ fieldName: 'customerCart', broadcast: true })
}

0 comments on commit a8ca29a

Please sign in to comment.