0

How to change the quantity of cart items in the checkout? I have a select that should display the quantity of items in the cart. When changing the value, change the quantity of goods in the basket and recalculate the total amount of the order.

File: Magento_Checkout/web/template/summary/item/details.html

<select 
   data-bind="options: qtyOptions, value: selectedQty, event: {change: updateQty($parent)}"
   class="cart-item__select js-cart-qty"
>
</select>

module-checkout/view/frontend/web/js/view/summary/item/details.js

updateQty: function(item) {
        var data = {
            item_id: item.item_id,
            item_qty: this.selectedQty()
        }

        $.ajax({
            url: url.build('checkout/cart/updateItemQty'),
            data: data,
            type: 'post',
            dataType: 'json',
            context: this,
        }).done(function (response) {
                alert('hey! you updated successfully, checkout cart.')
                console.log(response)
            })
            .fail(function (error) {
                console.log(JSON.stringify(error));
        });
    }

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.