tvog
(theo)
August 24, 2022, 7:17am
1
Hello,
When I add an item to the cart, and close the cart, view goes back to the top of the page. Everytime.
Also, can you let me know how I can display the item quantity I have in my cart ? The number don’t show off.
Can you please let me know how to fix that ? Thanks a lot !
Read-only link : https://preview.webflow.com/preview/hereticcoffee?utm_medium=preview_link&utm_source=designer&utm_content=hereticcoffee&preview=e1424927a9c764fb8378d4b519b61de3&workflow=preview
Have a great day,
Théo
tvog
(theo)
August 25, 2022, 7:23am
2
Hello, up. Can someone help ?
tvog
(theo)
August 26, 2022, 7:14am
3
Up, please any solution ?
tvog
(theo)
August 27, 2022, 8:58am
4
Can someone help ? Would love to have a solution
tvog
(theo)
August 30, 2022, 3:58pm
5
Hello, is it possible to have a solution ? Or something I should try ? Thanks.
Tvog, were you able to figure this out? Struggling with the same issue and sad to see nobody answered your responses thus far. Would appreciate any help
Codelias
(Codelias)
December 13, 2024, 10:51pm
7
I’ve figured it out
document.addEventListener('DOMContentLoaded', function() {
let savedScrollPosition = 0;
const cartWrapper = document.querySelector('.w-commerce-commercecartwrapper');
if (!cartWrapper) {
console.error('Cart wrapper not found');
return;
}
function handleCartStateChange(mutations) {
for (let mutation of mutations) {
if (mutation.type === 'attributes' && mutation.attributeName === 'data-cart-open') {
const isCartOpen = cartWrapper.getAttribute('data-cart-open') !== null;
if (isCartOpen) {
console.log('Cart has opened');
savedScrollPosition = window.pageYOffset;
console.log('Body scroll position:', savedScrollPosition);
document.body.style.top = `-${savedScrollPosition}px`;
document.body.style.position = 'fixed';
document.body.style.width = '100%';
} else {
console.log('Cart has closed');
document.body.style.position = '';
document.body.style.top = '';
document.body.style.width = '';
window.scrollTo(0, savedScrollPosition);
console.log('Scroll action has fired');
}
}
}
}
const observer = new MutationObserver(handleCartStateChange);
observer.observe(cartWrapper, { attributes: true, attributeFilter: ['data-cart-open'] });
});
Shalom_Omo
(Shalom Omo)
February 8, 2025, 12:40am
8
Also having same issue, I still have not found a solution yet. Sad that the Webflow team has not responded since this question was asked since Aug 2022!!!
memetican
(Michael Wells)
February 8, 2025, 1:54am
9
Hi Shalom, this is a community forum, the Webflow team doesn’t generally message here. You should open a ticket with support when you cannot find a solution here.
You should obviously try the solution just above, first.