A data-agnostic Web Component for numerical input handling.
The component automatically passes all data-* attributes assigned to the <wudo-quantity> element into the quantity:update event detail.
If you need to update a cart via AJAX, pass your identifiers as data attributes:
<wudo-quantity data-id="123" data-action="update-cart">...</wudo-quantity>JavaScript:
document.addEventListener('quantity:update', (e) => {
const { value, id, action } = e.detail;
if (action === 'update-cart') {
console.log(`Updating item ${id} to quantity ${value}`);
}
});