1

In checkout I have custom ajax request, script to remove a product in checkout. After that update cart section, all works, but I can't update cart qty title "1 item in cart".

How can I update it?

  • Which template file is generating the "1 item in cart" text you are trying to change? – thaddeusmt Dec 2 '17 at 1:13
  • 1
    @thaddeusmt vendor/magento/module-checkout/view/frontend/web/template/summary/cart-items.html – omelandr Dec 4 '17 at 9:01
1

I finded solution.

  1. In my extension created file requirejs-config.js added code:
var config = {
    config: { mixins: {
        'Magento_Checkout/js/view/summary/cart-items': {
            'Vendor_Module/js/view/summary/cart-items': true
        }
    }
    }
};
  1. create mixin file located in Vendor_Module/js/view/summary/cart-items.js and changed function getItemsQty
define(
    [
        'ko',
        'Magento_Checkout/js/model/totals',
        'uiComponent',
        'Magento_Checkout/js/model/step-navigator',
        'Magento_Checkout/js/model/quote'
    ],
    function (ko, totals, Component, stepNavigator, quote) {

        'use strict';

        var mixin = {
            getItemsQty: function() {
                var live_qty = parseInt(totals.getItems()().length, 10);
                var qty = this.totals.items_qty;
                if(live_qty != qty){
                    qty = live_qty;
                }
                return parseFloat(qty);
            }
        };

        return function (target) {
            return target.extend(mixin);
        };

    }
);

It works for me. Magento 2.1.6

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.