Hi,
In Horizon theme on the product page. The quantity is not resetting when I switch variants. Is there a way to do this by adding code or some such?
Thank you so much!
Hi,
In Horizon theme on the product page. The quantity is not resetting when I switch variants. Is there a way to do this by adding code or some such?
Thank you so much!
Hi @ambullseye,
Please send the website link, I will check it for you
When in Customizer, add a “Custom liquid” section to the “Footer” section group.
Paste this code:
<script>
document.addEventListener("variant:update", e => {
const sectionId = e.target.dataset.sectionId;
const qtyInput = document.querySelector(`[data-section-id=${sectionId}] [name=quantity]`);
if (qtyInput) qtyInput.value = 1;
})
</script>
Thank you for your reply. A quick question: what us the “Footer” section group? I don’t see that here.
Just wow! That totally worked! I never would have thought to put anything like that in the footer. Thank you for your help!!! I hope this thread finds others who have the same question.
Putting code in “Footer” means it will be applied on every page of the site as opposed to putting it into “Template” area.
So the code will also work for quick add popups on collection pages…