How to get event in liquid when product quantity is changed in PDP and cart page ???
Hi @Amith_M, what do you mean? In Shopify’s Liquid templating language, there is no built-in event listener for changes in product quantity. You can use JavaScript to do it dynamically.
For example:
document.addEventListener("DOMContentLoaded", function () {
const quantityInput = document.querySelector('input[name="quantity"]');
if (quantityInput) {
quantityInput.addEventListener("input", function (event) {
console.log("New quantity: ", event.target.value);
// You can trigger any custom function here
});
}
});
Thank you. I was searching for the answer in the doc.