ADD TO CART ANIMATION NOT WORKING PROPERLY ON THE PRODUCT PAGE. HOMEPAGE ITS WORKING FINE, KINDLY HELP ME.
LINK - https://78axlfc3odzqtxi3-71576191201.shopifypreview.com
PASSWORD - 678543
A user is experiencing an issue where the “Add to Cart” animation works correctly on the homepage but malfunctions on product pages. Specifically, when the “Adding…” text appears after clicking the button, the original “Add to Cart” text remains visible instead of being hidden.
Proposed Solutions:
background-color: white; to the button and <span>Adding...</span> elementsproduct-template.liquid or product-form.liquid.hidden class to control visibilityCurrent Status:
The issue remains unresolved. The user clarified that this functionality previously worked and is already built into the theme, suggesting the existing code may need adjustment rather than complete replacement. They’ve requested more specific guidance on exact placement and positioning of the suggested code fixes.
ADD TO CART ANIMATION NOT WORKING PROPERLY ON THE PRODUCT PAGE. HOMEPAGE ITS WORKING FINE, KINDLY HELP ME.
LINK - https://78axlfc3odzqtxi3-71576191201.shopifypreview.com
PASSWORD - 678543
Hi @Shahil1
The button code should go into the product form, where the “Add to Cart” button is located.
Steps:
The JavaScript code handles the dynamic behavior of the button.
Steps:
document.addEventListener('DOMContentLoaded', () => {
const button = document.getElementById('ProductSubmitButton-template--18852890542305__main');
if (button) {
button.addEventListener('click', function (event) {
event.preventDefault();
const addToCartText = button.querySelector('.cta');
const addingText = button.querySelector('.loading-overlay__spinner');
addToCartText.classList.add('hidden');
addingText.classList.remove('hidden');
setTimeout(() => {
addingText.classList.add('hidden');
addToCartText.classList.remove('hidden');
}, 2000);
});
}
});
The CSS styles the button and handles the hidden class.
Steps:
.hidden {
display: none;
}
.loading-overlay__spinner {
display: inline-block;
}
If my reply is helpful, kindly click like and mark it as an accepted solution.
If you are happy with my help, you can help me buy a COFFEE
Thanks!
Didnt work
, it was working before . Infact the theme already has this .
There is some issue with the current code only , maybe need to add some
code somewhere
please elaborate where to exactly paste this, and which position.
currently when the addin… is shown the add to cart is not hidden just in product page