1

We want to create a input field, that loads the qty of the latest item added to the cart and when changing this input field, it should change the qty of that item in the cart.

The first part, to check the qty that works fine. But how can we also make it possible to use this input field, to update the qty of that item in the cart?

See code below. What are we missing here?

<?php $cart->getQuote()->getItemsCollection(); $latestItem = $itemsCollection->getLastItem();?> <input id="cart-<?= /* @escapeNotVerified */ $latestItem->getId() ?>-qty" name="cart[<?= /* @escapeNotVerified */ $latestItem->getId() ?>][qty]" data-cart-item-id="<?= /* @escapeNotVerified */ $latestItem->getSku() ?>" value="<?= /* @escapeNotVerified */ $latestItem->getQty() ?>" type="number" size="2" title="<?= $block->escapeHtml(__('Qty')) ?>" class="input-text qty" data-validate="{required:true,'validate-greater-than-zero':true}"> 
0

1 Answer 1

0

Where do u want to create this field? This input should be part of cart <form>. Then you need to submit this form to apply the changes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.