By default, the cart page requires users to click "Update Shopping Cart" after changing item quantities. This conservative UI prioritizes simplicity in Hyvä.
To enable automatic (Ajax-based) quantity updates, customize the `Magento_Checkout/templates/php-cart/item/default.phtml` template.
Add the following event listener to the quantity input field. This will automatically submit the form two seconds after a visitor changes the quantity:
x-on:change.debounce.2000ms="$event.target.form && $event.target.form.dispatchEvent(new Event('submit', { cancelable: true }));"
Here is the full input field code for reference:
<input
id="cart-<?= $escaper->escapeHtmlAttr($item->getId()) ?>-qty"
name="cart[<?= $escaper->escapeHtmlAttr($item->getId()) ?>][qty]"
value="<?= $escaper->escapeHtmlAttr($block->getQty()) ?>"
type="number"
size="4"
step="any"
title="<?= $escaper->escapeHtmlAttr(__('Qty')) ?>"
class="qty form-input px-2 py-2 w-20 text-center"
required
min="0"
@change.debounce.2000ms="$event.target.form && $event.target.form.dispatchEvent(new Event('submit', { cancelable: true }));"
data-role="cart-item-qty"
>
Using `dispatchEvent` on the form triggers JavaScript submission events, including `hyva.postCart`, which reloads cart data via Ajax without a full page refresh.
If you prefer not to use Ajax but still want automatic quantity updates, use this instead: