Closed bloodf closed 3 years ago
Facing the same issue. getting the isTotalsSyncRequired, which is causing the cart not to update the totals if magento value is updated and i call the 'cart/sync'
We have seen this issue also in our project so I investigated some time to find the issue.
The bug has occured since the change https://github.com/DivanteLtd/vue-storefront/pull/4387. With this change the cart hash changes too early inside the flow of the function updateTotalsAfterMerge
and so results into not finishing the total sync.
updateTotalsAfterMerge
is checking for getters.isTotalsSyncRequired
, which is true
because the cart hash changed.syncTotals
syncTotals
the getters.isTotalsSyncRequired
is still true
pullMethods
pullMethods
the getters.isTotalsSyncRequired
is still true
syncShippingMethods
syncShippingMethods
finished, the getters.isTotalsSyncRequired
is false
instead of true
.syncTotals
will NOT continue because getters.isTotalsSyncRequired
is false
. But we would expect that it should continue, we want a sync.force the server sync inside updateTotalsAfterMerge
:
if (getters.isTotalsSyncRequired && clientItems.length > 0) {
await dispatch('syncTotals', { forceServerSync: true })
}
Another workaround could be to revert https://github.com/DivanteLtd/vue-storefront/pull/4387. But I would expect that this results into other bugs, that are currently unknown to me.
I don't know how to finally fix this. Hopefully a core developer may help here.
@revlis-x thank you for the hint. I've created an additional issue to be sure that the missing await
will be investigated: https://github.com/DivanteLtd/vue-storefront/issues/5165
@pschaub I came to the same workaround with forceServerSync: true
when i debugged this. Thanks for your time to write this down.
I just wanted to add, I also had to await
the 'addItem' calls in mergeServerItem
to make i work consistently...
From vue-storefront created by revlis-x: vuestorefront/vue-storefront#5007
Current behavior
When a guest cart with items gets merged with previously added account cart items after login, cart totals are not updated.
Expected behavior
Cart Totals should be updated after merging the cart,
Steps to reproduce the issue
Version of Vue Storefront
Additional information
isTotalsSyncRequired
Getter is false whenupdateTotalsAfterMerge
is called in this scenario.